dry-clean.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <view class="dry-clean-box iPhone-bottom flex-common-css box-border-box">
  3. <Nav title='干洗'></Nav>
  4. <view class="head-box box-border-box p-24 flex-justify-space">
  5. <image v-if="!siteData.logo" src="@/static/img/logo/logo.png" mode="aspectFill"></image>
  6. <image v-else :src="siteData.logo" mode="aspectFill"></image>
  7. <view class="flex-1">
  8. <view class="display-flex mb-16">
  9. <view class="w410 fs-40 fw-600 text-overflow-ellipsis-one">{{siteData.name?siteData.name:'请选择站点'}}
  10. </view>
  11. <view class="fs-28 fw-400 fc-41ABF5 text-align-right" @click="selectsShop()">【切换站点】</view>
  12. </view>
  13. <view class="display-flex">
  14. <view v-if="siteData.city_name||siteData.address" class="w410 fs-26 fw-400 fc-9">
  15. {{siteData.city_name}}{{siteData.address}}
  16. </view>
  17. <view v-else class="w410 fs-26 fw-400 fc-9">请选择站点已提供服务</view>
  18. <!-- <view class="text-align-center" style="margin-left: auto;">
  19. <view class="text-align-right">
  20. <uni-icons type="location" size="20"></uni-icons>
  21. </view>
  22. <view class="fs-26 fc-9">{{siteData.distance||'0'}}km</view>
  23. </view> -->
  24. </view>
  25. </view>
  26. </view>
  27. <view class="box-border-box p-24" @click="openText()">
  28. <view class="sy-box flex-justify-space box-border-box p-16">
  29. <view class="align-items-center">
  30. <uni-icons type="help" size="20" color="#666"></uni-icons>
  31. <view class="fc-6 fs-28 ml-10">使用须知</view>
  32. </view>
  33. <image src="@/static/img/toRight.png" mode=""></image>
  34. </view>
  35. </view>
  36. <!-- 列表 -->
  37. <view class="common-view-css bgc-f" style="overflow: hidden;">
  38. <Menu ref="menuBox" style="height: 100%;" @relCardBuy='relCardBuy'></Menu>
  39. </view>
  40. <view class="shop-buttom-money box-border-box">
  41. <view class="shop-buttom-money-1 flex-justify-space align-items-center">
  42. <image src="@/static/img/takeout/buy-icon.png" mode="scaleToFill" @click="openBuyCrad()"></image>
  43. <view class="shop-buttom-num fs-24 fc-f text-align-center" @click="openBuyCrad()">
  44. {{cardData.total_num||'0'}}
  45. </view>
  46. <view class="">
  47. <view class="">
  48. <span class="fw-600 fs-24 fc-f">¥</span>
  49. <span class="fw-600 fs-44 fc-f">{{cardData.total_price||'0'}}</span>
  50. </view>
  51. </view>
  52. <view class="shop-buttom-money-2 text-align-center fc-f fs-32 fw-600" @click="createOrder()">去结算</view>
  53. </view>
  54. </view>
  55. <uni-popup ref="popupBuy" type="bottom">
  56. <view class="buy-card flex-index-css">
  57. <view class="buy-card-top box-border-box plr-32 flex-justify-space align-items-center">
  58. <view class="">
  59. <span class="fs-32 fc-3 mr-12">已选商品</span>
  60. </view>
  61. <view class="fs-28 fw-400 fc-9 align-items-center">
  62. <view class="">
  63. <uni-icons type="trash" size="18" color="#999"></uni-icons>
  64. </view>
  65. <view class="fs-28 fw-400 fc-9" @click="cardAllDel()">清空</view>
  66. </view>
  67. </view>
  68. <view class="scroll-view-css box-border-box p-32">
  69. <view class="buy-card-item display-flex" v-for="(item,i) in cardData.goods_list" :key="i">
  70. <image class="goods_img" :src="item.goods_image" mode="scaleToFill"></image>
  71. <view class="flex-1">
  72. <view class="w-514 text-overflow-ellipsis-one fs-34 fw-600 mb-40">{{item.goods_name}}</view>
  73. <view class="flex-justify-space">
  74. <view class="">
  75. <span class="fs-24 fc-FB3D03 fw-400">¥</span>
  76. <span class="fs-40 fc-FB3D03 fw-b">{{item.price}}</span>
  77. </view>
  78. <view class="display-flex align-items-center">
  79. <!-- <view v-show="item.number > 0"
  80. class="right-only-right-red fw-500 text-align-center fs-36 fc-f"
  81. @click="addred(1,item)">-</view> -->
  82. <image v-show="item.number > 0" class="wh-44" @click="addred(1,item)"
  83. src="@/static/img/takeout/j.png" mode=""></image>
  84. <view v-show="item.number > 0"
  85. class="right-only-right-2 text-align-center fs-28 fw-400">{{item.number}}</view>
  86. <image class="wh-44" src="@/static/img/takeout/add.png" @click="addred(2,item)"
  87. mode=""></image>
  88. <!-- <view class="right-only-right-add fw-500 text-align-center fs-36 fc-f"
  89. @click="addred(2,item)">+</view> -->
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <view class="shop-buttom-money box-border-box" @click="createOrder()">
  96. <view class="shop-buttom-money-1 flex-justify-space align-items-center">
  97. <image src="@/static/img/takeout/buy-icon.png" mode="scaleToFill"></image>
  98. <view class="shop-buttom-num fs-24 fc-f text-align-center">{{cardData.total_num||'0'}}</view>
  99. <view class="">
  100. <view class="">
  101. <span class="fw-600 fs-24 fc-f">¥</span>
  102. <span class="fw-600 fs-44 fc-f">{{cardData.total_price||'0'}}</span>
  103. </view>
  104. </view>
  105. <view class="shop-buttom-money-2 text-align-center fs-32 fc-f fw-600">去结算</view>
  106. </view>
  107. </view>
  108. </view>
  109. </uni-popup>
  110. <uni-popup ref="popupText" type="bottom">
  111. <view class="use-box box-border-box p-16">
  112. <view class="head-pop flex-justify-space align-items-center mb-24">
  113. <uni-icons type="closeempty" size="24" color="#fff"></uni-icons>
  114. <view class="fs-36 fc-0 fw-600">使用须知</view>
  115. <uni-icons @click.stop="closeMsg()" type="closeempty" size="24"></uni-icons>
  116. </view>
  117. <view class="scroll-view-css" v-html="laundry_str"></view>
  118. </view>
  119. </uni-popup>
  120. </view>
  121. </template>
  122. <script>
  123. import {
  124. setShopIngNumber,
  125. setShopIngDel,
  126. getShopIngList,
  127. setShopIngAdd,
  128. } from '@/api/shopping.js'
  129. import {
  130. getCommonText
  131. } from '@/api/common.js';
  132. import Menu from './dry-mod/menu.vue';
  133. import tools from "@/service/tools";
  134. export default {
  135. components: {
  136. Menu
  137. },
  138. data() {
  139. return {
  140. laundry_str: '',
  141. siteData: {
  142. id: '',
  143. school_id: '',
  144. name: '',
  145. logo: '',
  146. distance: 0,
  147. city_name: '',
  148. address: '',
  149. },
  150. cardData: {
  151. goods_list: [],
  152. total_num: 0,
  153. total_price: 0,
  154. },
  155. isAJAX: false,
  156. }
  157. },
  158. onLoad(e) {
  159. if (e.data) {
  160. this.siteData = JSON.parse(decodeURIComponent(e.data));
  161. }
  162. },
  163. onShow() {
  164. this.getText();
  165. this.getCardList();
  166. },
  167. methods: {
  168. cardAllDel() {
  169. if (this.cardData.goods_list.length > 0) {
  170. setShopIngDel({
  171. type: 3
  172. }).then((res) => {
  173. if (res.code === 1) {
  174. this.cardData.goods_list = [];
  175. this.getCardList();
  176. this.$refs.menuBox.getTypeList();
  177. } else {
  178. tools.error('清空失败')
  179. }
  180. })
  181. } else {
  182. tools.error('暂未选择商品')
  183. }
  184. },
  185. relCardBuy() {
  186. // 重置购物车
  187. this.getCardList();
  188. },
  189. getCardList() {
  190. getShopIngList({
  191. type: 3
  192. }).then((res) => {
  193. if (res.code === 1) {
  194. this.cardData = res.data;
  195. }
  196. })
  197. },
  198. getText() {
  199. getCommonText().then((res) => {
  200. if (res.code === 1) {
  201. this.laundry_str = res.data.laundry_str
  202. }
  203. })
  204. },
  205. selectsShop() {
  206. uni.navigateTo({
  207. url: '/pages-buy/dry-mod/select-shop?id=' + this.siteData.id
  208. })
  209. },
  210. openText() {
  211. this.$refs.popupText.open()
  212. },
  213. closeMsg() {
  214. this.$refs.popupText.close()
  215. },
  216. openBuyCrad() {
  217. this.$refs.popupBuy.open()
  218. },
  219. addred(type, info) {
  220. if (this.isAJAX) {
  221. return
  222. }
  223. this.isAJAX = true;
  224. if (type === 1) {
  225. // 减
  226. setShopIngNumber({
  227. type: 3,
  228. goods_id: info.goods_id,
  229. category_id: info.category_id,
  230. operation: 2
  231. }).then((res) => {
  232. if (res.code === 1) {
  233. this.isAJAX = false;
  234. info.num -= 1;
  235. this.getCardList();
  236. this.$refs.menuBox.getTypeList();
  237. } else {
  238. this.isAJAX = false;
  239. tools.error(res.msg)
  240. }
  241. })
  242. } else if (type === 2) {
  243. // 加
  244. setShopIngAdd({
  245. type: 3,
  246. goods_id: info.goods_id,
  247. category_id: info.category_id
  248. }).then((res) => {
  249. if (res.code === 1) {
  250. this.isAJAX = false;
  251. info.num += 1;
  252. this.getCardList();
  253. this.$refs.menuBox.getTypeList();
  254. } else {
  255. this.isAJAX = false;
  256. tools.error(res.msg)
  257. }
  258. })
  259. }
  260. },
  261. createOrder() {
  262. if (this.cardData.goods_list.length == 0) {
  263. return tools.error('请选择商品')
  264. }
  265. if (!this.siteData.id) {
  266. return tools.error('请选择站点')
  267. }
  268. uni.navigateTo({
  269. url: '/pages-buy/save-dry?id=' + this.siteData.id + '&siteData_logo=' + this.siteData.logo +
  270. '&siteData_name=' + this.siteData.name
  271. })
  272. },
  273. },
  274. }
  275. </script>
  276. <style scoped lang="scss">
  277. .wh-44 {
  278. width: 44rpx;
  279. height: 44rpx;
  280. }
  281. .use-box {
  282. width: 100%;
  283. height: 70vh;
  284. background-color: #fff;
  285. border-radius: 24rpx 24rpx 0rpx 0rpx;
  286. display: flex;
  287. flex-direction: column;
  288. .head-pop {
  289. padding-bottom: 34rpx !important;
  290. border-bottom: 1rpx solid #F2F2F2;
  291. }
  292. }
  293. .dry-clean-box {
  294. background-color: #fff;
  295. .right-only-right-red {
  296. width: 44rpx;
  297. height: 44rpx;
  298. line-height: 40rpx;
  299. border-radius: 12rpx;
  300. border: 1rpx solid #41ABF5;
  301. color: #41ABF5;
  302. }
  303. .right-only-right-add {
  304. width: 44rpx;
  305. height: 44rpx;
  306. line-height: 40rpx;
  307. background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
  308. border-radius: 12rpx;
  309. }
  310. .right-only-right-2 {
  311. min-width: 50rpx;
  312. }
  313. .w-514 {
  314. width: 514rpx;
  315. }
  316. .w410 {
  317. width: 410rpx;
  318. }
  319. .head-box {
  320. background-color: #fff;
  321. box-shadow: 0rpx 8rpx 8rpx 0rpx rgba(51, 51, 51, 0.06);
  322. image {
  323. width: 100rpx;
  324. height: 100rpx;
  325. border-radius: 8rpx;
  326. margin-right: 18rpx;
  327. }
  328. }
  329. .sy-box {
  330. width: 100%;
  331. height: 60rpx;
  332. background: #F2F2F2;
  333. border-radius: 16rpx 16rpx 16rpx 16rpx;
  334. image {
  335. width: 32rpx;
  336. height: 32rpx;
  337. }
  338. }
  339. .shop-buttom-money {
  340. width: 100%;
  341. height: 140rpx;
  342. background: rgba(255, 255, 255, 0.8);
  343. padding: 20rpx 24rpx;
  344. .shop-buttom-money-1 {
  345. width: 100%;
  346. height: 100%;
  347. background: #333333;
  348. border-radius: 200rpx;
  349. box-sizing: border-box;
  350. padding-left: 136rpx;
  351. // padding-right: 32rpx;
  352. position: relative;
  353. image {
  354. position: absolute;
  355. bottom: 0;
  356. left: 8rpx;
  357. width: 128rpx;
  358. height: 128rpx;
  359. }
  360. .shop-buttom-num {
  361. width: 32rpx;
  362. height: 32rpx;
  363. line-height: 32rpx;
  364. background: #FB3D03;
  365. border-radius: 50%;
  366. position: absolute;
  367. top: 36rpx;
  368. left: 82rpx;
  369. }
  370. .shop-buttom-money-2 {
  371. width: 200rpx;
  372. height: 100rpx;
  373. line-height: 100rpx;
  374. background: #41ABF5;
  375. border-radius: 0rpx 200rpx 200rpx 0rpx;
  376. }
  377. }
  378. }
  379. .buy-card {
  380. height: 828rpx;
  381. background-color: #fff;
  382. border-radius: 24rpx 24rpx 0rpx 0rpx;
  383. .buy-card-top {
  384. width: 100%;
  385. height: 92rpx;
  386. background: #FCF5DB;
  387. border-radius: 24rpx 24rpx 0rpx 0rpx;
  388. }
  389. .buy-card-item {
  390. width: 100%;
  391. height: 176rpx;
  392. margin-bottom: 32rpx;
  393. .goods_img {
  394. width: 152rpx;
  395. height: 152rpx;
  396. border-radius: 12rpx;
  397. margin-right: 20rpx;
  398. }
  399. }
  400. }
  401. }
  402. </style>