confirm.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <view>
  3. <view class="order-type">
  4. <view :class="service_type==2?'type-item active':'type-item'" @click="service_type=2">代提</view>
  5. <view :class="service_type==1?'type-item active':'type-item'" @click="service_type=1">自提</view>
  6. </view>
  7. <view class="order-content" v-if="goodsInfo">
  8. <view class="address" v-if="storeInfo && service_type==2">
  9. <view class="addressInfo" v-if="addressInfo" @click="toAddress">
  10. <view class="empty-data">
  11. <view class="icon"><image src="/static/image/location.png"></image></view>
  12. <view class="left">
  13. <view class="region">{{addressInfo.region}}</view>
  14. <view class="address">{{addressInfo.address}}</view>
  15. <view class="contact-name">{{addressInfo.username}} <view class="mobile">{{addressInfo.mobile}}</view></view>
  16. </view>
  17. <view class="right"><image src="/static/image/right.png"></image></view>
  18. </view>
  19. </view>
  20. <view class="empty-address" @click="toAddress" v-else>
  21. <view class="name">完善会员信息</view>
  22. <view class="desc">请先完善会员信息后再进行确认兑换</view>
  23. <view class="btn-group"><button class="btn">去完善</button></view>
  24. </view>
  25. </view>
  26. <view class="order-time" v-if="storeInfo && service_type==1" @click="selectTime(1)">
  27. <view class="time-icon"><image src="/static/image/time.png"></image></view>
  28. <view class="title">
  29. <view class="p">预约到店时间</view>
  30. <view class="desc" v-if="!timeStr">请选择预计到店服务的时间</view>
  31. </view>
  32. <view class="msg">
  33. {{timeStr?timeStr:'请选择'}}
  34. <view class="right"><image src="/static/image/right.png"></image></view>
  35. </view>
  36. </view>
  37. <view class="goods">
  38. <view class="goods-info">
  39. <view class="image"><image :src="goodsInfo.goods.product_img"></image></view>
  40. <view class="info">
  41. <view class="name">{{ goodsInfo.product_name }}</view>
  42. <view class="desc">x {{goodsInfo.count}}</view>
  43. <view class="desc">有效期至{{goodsInfo.expire_at}}</view>
  44. </view>
  45. <view class="price">¥{{goodsInfo.order_amount}}</view>
  46. </view>
  47. <!-- <view class="goods-item">
  48. <view class="left">商品总额</view>
  49. <view class="right">¥{{goodsInfo.order_amount}}</view>
  50. </view>
  51. <view class="goods-item">
  52. <view class="left">商品优惠</view>
  53. <view class="right red">¥{{goodsInfo.order_amount}}</view>
  54. </view> -->
  55. </view>
  56. <view class="goods_skus" v-if="goodsSku.length > 0">
  57. <view class="sku_box" v-for="(item,indx) in goodsSku" :key="indx">
  58. <view class="sku_name">
  59. {{item.name}}({{item.list.length}}选{{item.num}})<text>点击图片可放大查看</text>
  60. <view class="right" @click="clearSku(indx)">清除</view>
  61. </view>
  62. <view class="sku_list">
  63. <view :class="itm.check?'sku_item':'sku_item active'" v-for="(itm,iddx) in item.list" :key="iddx">
  64. <view class="img" v-if="itm.img" @click="skuCheck(item.name,item.num,indx,iddx)"><image :src="itm.img"></image></view>
  65. <view :class="itm.img?'name':'name ac'" @click="skuCheck(item.name,item.num,indx,iddx)">{{itm.name}}</view>
  66. <view class="pre" @click="viewImg(itm.img)" v-if="itm.img"><image src="/static/image/open.png"></image></view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="location" @click="toDetail">
  72. <view class="left">
  73. <view class="name">{{poi_name}}</view>
  74. <view class="desc"><image src="/static/image/location.png"></image>距您{{juli}}公里</view>
  75. </view>
  76. <view class="right"><image src="/static/image/right.png"></image></view>
  77. </view>
  78. <view class="order-msg">
  79. <view class="title">订单备注</view>
  80. <view class="msg"><textarea class="textarea" placeholder="请输入" v-model="msg" :rows="5"></textarea></view>
  81. </view>
  82. </view>
  83. <view class="goods-info" v-else>
  84. <u-skeleton
  85. rows="3"
  86. title
  87. loading
  88. ></u-skeleton>
  89. </view>
  90. <view class="line"></view>
  91. <view class="flx-footer">
  92. <view class="footer-btn" v-if="goodsInfo">
  93. <view class="price"><text class="desc">已优惠:¥{{goodsInfo.order_amount}},</text>合计<text class="money">¥0.00</text></view>
  94. <view class="btn-group"><button :disabled="disabled" @click="submitOrder" class="btn">{{disabled?'处理中...':'确认兑换'}}</button></view>
  95. </view>
  96. <view class="footer-safe"></view>
  97. </view>
  98. <uni-popup ref="timepopup" type="bottom" borderRadius="10px 10px 0 0" backgroundColor="#F8F8F8">
  99. <view class="time-select">
  100. <view class="title">选择时间<view class="close" @click="selectTime(2)"><image src="/static/image/round_close.png"></image></view> </view>
  101. </view>
  102. <view class="time-body">
  103. <view class="time-left">
  104. <view :class="timeIndex==index?'time-left-item active':'time-left-item'" @click="timeCheck(index)" v-for="(item,index) in timeData">
  105. <view class="name">{{item.day}}</view>
  106. <view class="desc">{{item.week}}</view>
  107. </view>
  108. </view>
  109. <view class="time-right">
  110. <view :class="childIndex==index?'time-right-item active':'time-right-item'" @click="childCheck(index)" v-for="(item,index) in timeChildren">
  111. <view class="name">{{item.display}}</view>
  112. </view>
  113. </view>
  114. </view>
  115. <view class="time-btn">
  116. <button class="btn" @click="checkTimeEnd">确认选择</button>
  117. </view>
  118. </uni-popup>
  119. </view>
  120. </template>
  121. <script>
  122. var app;
  123. import * as Api from "@/static/api/order.js";
  124. export default {
  125. data() {
  126. return {
  127. disabled:false,
  128. timeIndex:0,
  129. childIndex:0,
  130. order:"",
  131. poi_name:"",
  132. poi_id:"",
  133. juli:"",
  134. goodsInfo:null,
  135. storeInfo:null,
  136. timeStr:null,
  137. timeState:false,
  138. timeData:[],
  139. timeChildren:[],
  140. addressInfo:null,
  141. msg:"",
  142. totalData:[],
  143. goodsSku:[],
  144. service_type:2
  145. }
  146. },
  147. onLoad({order,poi_id,poi_name,juli}) {
  148. app = this;
  149. app.order = order;
  150. app.poi_id = poi_id;
  151. app.poi_name = poi_name;
  152. app.juli = juli;
  153. app.getOrder();
  154. },
  155. methods: {
  156. viewImg(img){
  157. uni.previewImage({
  158. urls:[img]
  159. })
  160. },
  161. submitOrder(){
  162. var formData = {};
  163. formData.order = app.order;
  164. formData.poi_id = app.poi_id;
  165. if (app.service_type==2 && app.addressInfo == null) {
  166. return app.$dialog.showSuccess("请先完善会员信息");
  167. }
  168. if (app.service_type==1 && app.timeStr == null) {
  169. return app.$dialog.showSuccess("请选择预约时间");
  170. }
  171. formData.service_type = app.service_type;
  172. var skuInfo = "",skuState = true;
  173. if (app.goodsSku.length > 0) {
  174. app.goodsSku.forEach((item,index)=>{
  175. var skuCheck = [],skuI = 0;
  176. skuInfo += item.name+":";
  177. item.list.forEach((itm,idx)=>{
  178. if (itm.check==false){
  179. skuInfo += itm.name+',';
  180. skuCheck[skuI] = itm.name;
  181. skuI ++;
  182. }
  183. });
  184. skuInfo = skuInfo.slice(0, -1);
  185. skuInfo += ";";
  186. if (item.num > skuCheck.length) {
  187. app.$dialog.showSuccess("请完善【"+item.name+"】选项");
  188. skuState = false;
  189. return false;
  190. }
  191. });
  192. if (!skuState) return ;
  193. }
  194. formData.sku = skuInfo;
  195. formData.address = JSON.stringify(app.addressInfo);
  196. formData.time = app.timeStr;
  197. formData.remark = app.msg;
  198. app.disabled = true;
  199. Api.submit(formData).then((res)=>{
  200. app.disabled = false;
  201. if (res.code == 0) {
  202. return app.$dialog.showSuccess(res.msg);
  203. }
  204. app.$dialog.showSuccess(res.msg,"none",function(){
  205. uni.switchTab({
  206. url:"/pages/order/order"
  207. })
  208. });
  209. })
  210. },
  211. clearSku(parent){
  212. app.totalData = [];
  213. var goodsSku = app.goodsSku;
  214. goodsSku[parent].list.forEach((item,index) => {
  215. if (!item.check) {
  216. item.check = true;
  217. }
  218. })
  219. },
  220. skuCheck(name,length,parent,select){
  221. var goodsSku = app.goodsSku;
  222. if (length == '1') { // 单选
  223. goodsSku[parent].list.forEach((item,index) => {
  224. item.check = true;
  225. if (index == select) {
  226. item.check = false;
  227. app.skuInfo = goodsSku[parent].name+":"+item.name;
  228. }
  229. })
  230. } else { // 多选
  231. var data = [];
  232. var checkData = app.skuDataCheck(parent,length);
  233. goodsSku[parent].list.forEach((item,index) => {
  234. if (checkData >= length) {
  235. app.$dialog.showSuccess("清除后可重选~");
  236. return ;
  237. }
  238. if (index == select) {
  239. if (item.check) {
  240. data[parent+'_'+index] = item;
  241. }
  242. item.check = item.check?false:true;
  243. app.totalData.push(data)
  244. }
  245. });
  246. }
  247. app.goodsSku = goodsSku;
  248. },
  249. skuDataCheck(parent,length){
  250. var dataLen = 0;
  251. for (let key in app.totalData) {
  252. if (typeof app.totalData[key] == 'object' || typeof app.totalData[key] == 'array')
  253. {
  254. for (let indx in app.totalData[key]) {
  255. if (indx.includes(parent+"_")) {
  256. dataLen ++;
  257. }
  258. }
  259. }
  260. }
  261. return dataLen;
  262. },
  263. checkTimeEnd(){
  264. app.$refs.timepopup.close()
  265. var day = app.timeData[app.timeIndex];
  266. var fullday = day.full;
  267. var time = day.children[app.childIndex].display;
  268. app.timeStr = fullday+" "+time;
  269. },
  270. timeCheck(index){
  271. app.timeIndex = index;
  272. app.timeChildren = app.timeData[index].children
  273. },
  274. childCheck(index){
  275. app.childIndex = index;
  276. },
  277. getBackInfo(data){
  278. app.addressInfo = data;
  279. },
  280. toAddress(){
  281. uni.navigateTo({
  282. url:"/pages/user/address?type=2"
  283. })
  284. },
  285. selectTime(type){
  286. if (type == 1) {
  287. app.$refs.timepopup.open()
  288. }
  289. if (type == 2) {
  290. app.$refs.timepopup.close()
  291. }
  292. },
  293. getOrder(){
  294. Api.detail({"order":app.order}).then((res)=>{
  295. if (res.code == 0) {
  296. return app.$dialog.showSuccess(res.msg,"none",function(){
  297. uni.navigateBack()
  298. });
  299. }
  300. app.goodsInfo = res.data.order;
  301. app.storeInfo = res.data.store;
  302. app.timeData = res.data.time
  303. app.timeChildren = app.timeData[0].children
  304. app.goodsSku = res.data.specs;
  305. });
  306. },
  307. toDetail(){
  308. uni.navigateTo({
  309. url:"/pages/order/store?type=1&order="+app.order
  310. })
  311. },
  312. }
  313. }
  314. </script>
  315. <style>
  316. page{background-color: #f2f2f2;}
  317. .empty-address{text-align: center;box-shadow: 8px 8px 20px 0 rgba(55, 99, 170, .1);background-color: #fff;width: calc(95% - 40upx);margin: 20upx auto;padding: 20upx;border-radius: 20upx;}
  318. .empty-address .name{font-size: 36upx;font-weight: bold;color: #333;}
  319. .empty-address .desc{font-size: 26upx;color: #666;margin: 20upx 0;}
  320. .empty-address .btn-group{text-align: center;display: flex;align-items: center;justify-content: center;}
  321. .empty-address .btn-group .btn{font-size: 28upx;color: #fff;background-color: #fe2c56;width: 50%;}
  322. .order-content{overflow: auto;}
  323. .line{height: 200upx;width: 100%;}
  324. .order-type{height: 80upx;display: flex;align-items: center;line-height: 80upx;background-color: #fff;gap: 20upx;border-bottom: 2upx solid #f8f8f8;}
  325. .order-type .type-item{text-align: center;width: 50%;font-size: 32upx;color: #333;position: relative;border-left: 2upx solid #f8f8f8;}
  326. .order-type .type-item.active{color: #fe2c56;font-weight: bold;}
  327. .order-type .type-item.active::after{content: "";position: absolute;left: 40%;width: 20%;bottom: -5upx;height: 10upx;background-color: #fe2c56;}
  328. .addressInfo{}
  329. .addressInfo .empty-data{display: flex;align-items: center;font-size: 28upx;width: 100%;}
  330. .addressInfo .empty-data .icon{margin-right: 20upx;}
  331. .addressInfo .empty-data .icon image{width: 40upx;height: 40upx;}
  332. .addressInfo .empty-data .region{color: #666;font-size: 28upx;}
  333. .addressInfo .empty-data .address{color: #333;font-size: 32upx;margin: 10upx 0;}
  334. .addressInfo .empty-data .contact-name{display: flex;align-items: center;font-size: 28upx;color: #666;margin-bottom: 20upx;}
  335. .addressInfo .empty-data .contact-name .mobile{margin-left: 20upx;}
  336. .addressInfo .empty-data .desc{font-size: 26upx;color: #666;}
  337. .addressInfo .empty-data .left image{width: 40upx;height: 40upx;margin-right: 20upx;vertical-align: middle;}
  338. .addressInfo .empty-data .right image{width: 40upx;height: 40upx;vertical-align: middle;}
  339. .addressInfo .empty-data .right{margin-left: auto;margin-right: 0;}
  340. .time-body{height: 30vh;display: flex;align-items: center;}
  341. .time-body .time-left{width: 30%;background-color: #F5FAFD;height: 100%;overflow-y: auto;}
  342. .time-body .time-left .time-left-item{padding: 10upx;text-align: center;}
  343. .time-body .time-left .time-left-item.active{background-color: #fff;color: #fe2c56;}
  344. .time-body .time-left .time-left-item.active .name{color: #fe2c56;}
  345. .time-body .time-left .time-left-item.active .desc{color: #fe2c56;}
  346. .time-body .time-left .time-left-item .name{font-size: 28upx;color: #333;}
  347. .time-body .time-left .time-left-item .desc{font-size: 24upx;color: #666;}
  348. .time-body .time-right{width: calc(70% - 80upx);padding:0 40upx;background-color: #fff;height: 100%;overflow-y: auto;}
  349. .time-body .time-right .time-right-item{background-color: #F6FAFD;border: 2upx solid #ccc;height: 66upx;line-height: 66upx;text-align: center;font-size: 28upx;color: #333;margin-top: 20upx;border-radius: 10upx;}
  350. .time-body .time-right .time-right-item.active{color: #fe2c56;border: 2upx solid #fe2c56;}
  351. .time-select .title{height: 100upx;line-height: 100upx;display: flex;align-items: center;justify-content: space-between;font-size: 28upx;padding: 0 20upx;font-weight: bold;}
  352. .time-select image{width: 40upx;height: 40upx;vertical-align: middle;}
  353. .time-btn{padding: 20upx;}
  354. .location{background-color: #fff;padding: 20upx;width: calc(95% - 40upx);margin: 20upx auto;display: flex;align-items: center;justify-content: space-between;border-radius: 20upx;}
  355. .location .right image{width: 40upx;height: 40upx;vertical-align: middle;}
  356. .location .name{font-size: 32upx;color: #333;font-weight: bold;margin-bottom: 20upx;}
  357. .location .desc{color: #666;font-size: 28upx;display: flex;align-items: center;}
  358. .location .desc image{width: 40upx;height: 40upx;margin-right: 20upx;}
  359. .goods,.order-msg,.addressInfo{background-color: #fff;padding: 20upx;width: calc(95% - 40upx);margin: 20upx auto;border-radius: 20upx;}
  360. .goods .goods-info{display: flex;align-items: center;position: relative;}
  361. .goods .goods-info .price{color: #fe2c56;font-size: 32upx;font-weight: bold;position: absolute;bottom: 20upx;right: 20upx;}
  362. .goods .goods-info .info{flex: 1;margin-left: 20upx;}
  363. .goods .goods-info .image image{width: 160upx;height: 160upx;border-radius: 10upx;}
  364. .goods .goods-info .name{font-size: 32upx;color: #333;line-height: 46upx;margin-bottom: 15upx;}
  365. .goods .goods-info .desc{color: #666;font-size: 28upx;line-height: 48upx;}
  366. .goods .goods-item{display: flex;align-items: center;line-height: 80upx;justify-content: space-between;font-size: 28upx;color: #333;}
  367. .goods .goods-item .right.red{color: #fe2c56;}
  368. .order-time{background-color: #fff;padding: 20upx;width: calc(95% - 40upx);margin: 20upx auto;display: flex;align-items: center;border-radius: 20upx;}
  369. .order-time .title{font-size: 28upx;margin-left: 20upx;}
  370. .order-time .title .p{font-size: 28upx;color: #333;font-weight: bold;}
  371. .order-time .title .desc{font-size: 24upx;color: #666;margin-top: 10upx;}
  372. .order-time .time-icon image{width: 40upx;height: 40upx;}
  373. .order-time .right image{width: 40upx;height: 40upx;vertical-align: middle;}
  374. .order-time .msg{display: flex;align-items: center;font-size: 28upx;color: #333;margin-left: auto;margin-right: 0;}
  375. .order-msg .title{color: #333;font-size: 32upx;border-bottom: 2upx solid #f8f8f8;margin-bottom: 20upx;padding-bottom: 20upx;font-weight: bold;}
  376. .order-msg .textarea{width: 100%;height: 100upx;font-size: 28upx;}
  377. .flx-footer{position: fixed;bottom: 0;background-color: #fff;padding: 20upx;border-top: 2upx solid #f8f8f8;left: 0;right: 0;z-index: 99;}
  378. .flx-footer .footer-safe {height: env(safe-area-inset-bottom);width: 100%;}
  379. .flx-footer .btn,.time-btn .btn{font-size: 32rpx;height: 80upx;border-radius: 10upx;line-height: 80upx;text-align: center;width: 100%;color: #333;background-color: #fe2c56;color: #fff;border:2upx solid #fe2c56;}
  380. .flx-footer .btn[disabled],.flx-footer .btn.disabled{background-color: rgba(34, 77, 122, 0.3);}
  381. .flx-footer .footer-btn{display: flex;align-items: center;justify-content: space-between;}
  382. .flx-footer .footer-btn text.desc{color: #666;font-size: 28upx;}
  383. .flx-footer .footer-btn text.money{color: #fe2c56;font-size: 32upx;font-weight: bold;}
  384. .flx-footer .footer-btn .price{color: #333;font-size: 28upx;}
  385. .goods_skus{
  386. padding: 20upx 20upx 0 20upx;
  387. background-color: #fff;width: calc(95% - 40upx);margin: 0 auto;
  388. border-radius: 20upx;
  389. }
  390. .goods_skus .sku_name{
  391. font-size: 28upx;
  392. color: #000;
  393. line-height: 60upx;
  394. display: flex;
  395. align-items: center;
  396. }
  397. .goods_skus .sku_name text{margin-left: 20upx;color: #666;font-size: 24upx;}
  398. .goods_skus .sku_name .right{
  399. margin-left: auto;
  400. margin-right: 0;
  401. font-size: 26upx;
  402. color: #666;
  403. display: flex;
  404. align-items: center;
  405. }
  406. .goods_skus .sku_name .right image{
  407. width: 30upx;
  408. height: 30upx;
  409. margin-right: 10upx;
  410. }
  411. .goods_skus .sku_list{
  412. display: flex;
  413. align-items: center;
  414. margin: 10upx 0;
  415. flex-wrap: wrap;
  416. }
  417. .goods_skus .sku_list .sku_item.active{
  418. /* background: linear-gradient(90deg, rgba(254, 44, 86, 1) 0%, rgba(228, 100, 126, 1) 100%); */
  419. color: #fe2c56;
  420. border: 2upx solid #fe2c56;
  421. background-color: #ccc;
  422. }
  423. .goods_skus .sku_list .sku_item{
  424. background-color: #f8f8f8;
  425. border: 2upx solid #f8f8f8;
  426. margin-right: 20upx;
  427. margin-bottom: 20upx;
  428. border-radius: 5upx;
  429. font-size: 28upx;
  430. display: flex;
  431. align-items: center;
  432. flex-direction: column;
  433. position: relative;
  434. }
  435. .goods_skus .sku_list .sku_item .pre{position: absolute;top: 0;left: 0;width: 40upx;height: 40upx;background-color: rgba(0, 0, 0, 0.5);border-radius: 0 0 20upx 0;z-index: 99;display: flex;align-items: center;justify-content: center;}
  436. .goods_skus .sku_list .sku_item .pre image{width: 25upx;height: 25upx;}
  437. .goods_skus .sku_list .sku_item .img{width: 100upx;}
  438. .goods_skus .sku_list .sku_item .img image{width: 100%;height: 100upx;vertical-align: middle;margin-right: 10upx;}
  439. .goods_skus .sku_list .sku_item .name{height: 40upx;line-height: 40upx;flex: 1;width: 100%;text-align: center;font-size: 26upx;}
  440. .goods_skus .sku_list .sku_item .name.ac{padding: 10upx 20upx;height: 40upx;line-height: 40upx;}
  441. </style>