done.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <view class="content">
  3. <template v-if="loading">
  4. <view class="skeleton">
  5. <view class="skeleton-line max animate" style="height: 200upx;"></view>
  6. <view class="skeleton-line animate"></view>
  7. <view class="skeleton-line min animate"></view>
  8. <view class="skeleton-line min animate"></view>
  9. <view class="skeleton-line max animate" style="height: 200upx;"></view>
  10. <view class="skeleton-line max animate" style="height: 200upx;"></view>
  11. </view>
  12. </template>
  13. <template v-else>
  14. <scroll-view class="goods-body" scroll-y scroll-with-animation>
  15. <view class="order-body" v-if="orderData">
  16. <view class="item-goods">
  17. <view class="item-goods-body">
  18. <view class="image">
  19. <image :src="orderData.img"></image>
  20. </view>
  21. <view class="info">
  22. <view class="title">
  23. <view class="name" v-if="orderData.product.is_new==1">
  24. {{orderData.product.price}}元代{{orderData.product.line_price}}元商场权益券{{orderData.product.product_name}}
  25. </view>
  26. <view class="name" v-else>{{ orderData.product.product_name }}</view>
  27. <view class="num">x{{ orderData.number }}</view>
  28. </view>
  29. <view class="tags">
  30. {{orderData.sku_name?orderData.sku_name:'默认'}}
  31. <view class="price">{{ $dialog.formatMoney(orderData.price,true) }}</view>
  32. </view>
  33. <view class="price-right">实付 <text>{{ $dialog.formatMoney(orderData.pay_money,true) }}</text></view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="order-info">
  38. <view class="title-h">意向商品<text>(可选{{orderData.number}}份)</text></view>
  39. <view class="goods-item" v-for="(item,indx) in doneGoods" :key="indx">
  40. <view class="item-goods" style="padding: 10rpx;background-color: #f8f8f8;">
  41. <view class="item-goods-body">
  42. <view class="image">
  43. <image :src="item.image"></image>
  44. </view>
  45. <view class="info">
  46. <view class="title">
  47. <view class="name">{{ item.title }}</view>
  48. </view>
  49. <view class="tags">
  50. <view></view>
  51. <view class="price">x{{ item.number }}</view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="goods-item-check" @click="chooseGoods">{{doneGoods.length == 0 ? '请选择': '更换其他'}}</view>
  58. </view>
  59. <view class="order-info">
  60. <view class="title-h">会员信息</view>
  61. <view class="form-feedbak">
  62. <view class="title"><text>*</text>姓名</view>
  63. <view class="form-textarea">
  64. <input v-model="addressForm.nickname" data-field="nickname" placeholder="请输入" class="u-input" />
  65. </view>
  66. </view>
  67. <view class="form-feedbak">
  68. <view class="title"><text>*</text>手机号码</view>
  69. <view class="form-textarea">
  70. <input v-model="addressForm.mobile" data-field="mobile" placeholder="请输入" class="u-input" />
  71. </view>
  72. </view>
  73. <view class="form-feedbak">
  74. <view class="title"><text>*</text>所属地区</view>
  75. <view class="form-textarea" @click="showAddress">
  76. {{addressData.name}}
  77. </view>
  78. </view>
  79. <view class="form-feedbak">
  80. <view class="title"><text>*</text>详细地址</view>
  81. <view class="form-textarea">
  82. <input v-model="addressForm.address" data-field="address" placeholder="请输入" class="u-textarea" />
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="line-height"></view>
  88. </scroll-view>
  89. <view class="footer">
  90. <view class="footer-op">
  91. <view class="footer-right">
  92. <button :loading="isSubmit" :disabled="isSubmit" class="btn full" @click="submitOrder">提交</button>
  93. </view>
  94. </view>
  95. <view class="footer-safe"></view>
  96. </view>
  97. </template>
  98. <uni-popup ref="addressPop" type="bottom" border-radius="10px 10px 0 0" background-color="#ffffff" :mask-click="false">
  99. <view class="address-pop">
  100. <view class="address-check">
  101. <view class="check-name" @click="addTop(1,fristData.index)">{{fristData.name}}</view>
  102. <view class="check-name" @click="addTop(2,fristData.index)">{{secondData.name}}</view>
  103. <view class="check-name" @click="addTop(3,secondData.index)">{{threeData.name}}</view>
  104. </view>
  105. <view class="address-scroll">
  106. <template v-if="fristData.list.length > 0">
  107. <view :class="fristData.index==indx?'item-name active':'item-name'" v-for="(item,indx) in fristData.list" :key="indx" @click="addClick(indx,1)">
  108. {{ item.text }}
  109. <view class="icon"><image src="/static/image/gou.svg"></image></view>
  110. </view>
  111. </template>
  112. <template v-if="secondData.list.length > 0">
  113. <view :class="secondData.index==indx?'item-name active':'item-name'" v-for="(item,indx) in secondData.list" :key="indx" @click="addClick(indx,2)">
  114. {{ item.text }}
  115. <view class="icon"><image src="/static/image/gou.svg"></image></view>
  116. </view>
  117. </template>
  118. <template v-if="threeData.list.length > 0">
  119. <view :class="threeData.index==indx?'item-name active':'item-name'" v-for="(item,indx) in threeData.list" :key="indx" @click="addClick(indx,3)">
  120. {{ item.text }}
  121. <view class="icon"><image src="/static/image/gou.svg"></image></view>
  122. </view>
  123. </template>
  124. </view>
  125. <view class="address-footer">
  126. <view class="footer-btn" @click="closeOrder">取消</view>
  127. <view class="footer-btn full" @click="checkAddress">确定</view>
  128. </view>
  129. </view>
  130. </uni-popup>
  131. <goodsDialog ref="goodsDialog" @send="sendGoods"></goodsDialog>
  132. </view>
  133. </template>
  134. <script>
  135. var app;
  136. import goodsDialog from '@/components/chat/goods';
  137. import form from "@/static/js/form.js";
  138. export default {
  139. components: {
  140. goodsDialog
  141. },
  142. data() {
  143. return {
  144. optionData:null,
  145. orderData:null,
  146. loading:false,
  147. cityData:[],
  148. addressForm:{},
  149. isSubmit:false,
  150. addressData:{
  151. name:"请选择",
  152. hide:null,
  153. list:[]
  154. },
  155. fristData:{
  156. index:null,
  157. name:"",
  158. list:[]
  159. },
  160. secondData:{
  161. index:null,
  162. name:"",
  163. list:[]
  164. },
  165. threeData:{
  166. index:null,
  167. name:"",
  168. list:[]
  169. },
  170. doneGoods:[]
  171. }
  172. },
  173. onLoad(options) {
  174. app = this;
  175. app.optionData = options;
  176. const eventChannel = this.getOpenerEventChannel();
  177. this.getOrder();
  178. },
  179. methods: {
  180. async submitOrder(){
  181. if (app.doneGoods.length == 0) return app.$dialog.showSuccess("请选择意向商品");
  182. var formData = this.addressForm;
  183. var validation = form.validation(formData,[
  184. {name:"nickname",rule:["required"],msg:["请输入姓名"]},
  185. {name:"mobile",rule:["required","isMobile"],msg:["请填写手机号码","手机号码格式错误"]},
  186. {name:"address",rule:["required"],msg:["请输入"]},
  187. ]);
  188. if(validation){
  189. this.$dialog.showSuccess(validation);
  190. return false;
  191. }
  192. if (!app.addressData.hide) return app.$dialog.showSuccess("请选择地区");
  193. formData.goods = JSON.stringify(app.doneGoods);
  194. formData.city = JSON.stringify(app.addressData)
  195. formData.order = app.optionData.order
  196. app.isSubmit = true;
  197. var resp = await app.$api.order.address.post(formData);
  198. app.isSubmit = false;
  199. if (resp.code !== 1) return app.$dialog.showSuccess(resp.msg);
  200. app.$dialog.showSuccess(resp.msg);
  201. setTimeout(function(){
  202. const eventChannel = app.getOpenerEventChannel();
  203. eventChannel.emit('acceptKeepData', { msg: '会员信息已完善' });
  204. uni.navigateBack();
  205. },900)
  206. },
  207. chooseGoods(){
  208. this.$nextTick(()=>{
  209. this.$refs.goodsDialog.open().setData({"order":app.optionData.order,"num":app.orderData.number});
  210. })
  211. },
  212. sendGoods(data){
  213. app.doneGoods = data;
  214. },
  215. checkAddress(){
  216. if (!app.fristData.index) return this.$dialog.showSuccess("请完善地区信息!");
  217. if (!app.secondData.index) return this.$dialog.showSuccess("请完善地区信息~");
  218. if (!app.threeData.index) return this.$dialog.showSuccess("请完善地区信息");
  219. var fristData = app.cityData[app.fristData.index];
  220. var secondData = fristData.children[app.secondData.index];
  221. var threeData = secondData.children[app.threeData.index];
  222. app.addressData.name = fristData.text+"/"+secondData.text+"/"+threeData.text
  223. app.addressData.hide = fristData.text+secondData.text+threeData.text
  224. app.addressData.list = [fristData.value,secondData.value,threeData.value]
  225. app.$refs.addressPop.close()
  226. },
  227. addClick(indx,type) {
  228. if (type == 1) {
  229. app.fristData.index = indx;
  230. app.fristData.list = [];
  231. app.secondData.list = app.cityData[indx].children;
  232. app.fristData.name = app.cityData[indx].text;
  233. }
  234. if (type == 2) {
  235. app.secondData.index = indx;
  236. app.secondData.name = app.secondData.list[indx].text;
  237. app.threeData.list = app.secondData.list[indx].children;
  238. app.secondData.list = [];
  239. }
  240. if (type == 3) {
  241. app.threeData.index = indx;
  242. app.threeData.name = app.threeData.list[indx].text;
  243. }
  244. },
  245. addTop(type,index){
  246. if (type == 1) {
  247. app.fristData.list = app.cityData;
  248. app.secondData.list = [];
  249. app.secondData.index = null;
  250. app.secondData.name = null;
  251. app.threeData.list = [];
  252. app.threeData.index = null;
  253. app.threeData.name = null;
  254. }
  255. if (type == 2) {
  256. app.secondData.list = app.cityData[index].children;
  257. app.threeData.list = [];
  258. app.threeData.index = null;
  259. app.threeData.name = null;
  260. }
  261. },
  262. showAddress(){
  263. this.$refs.addressPop.open();
  264. },
  265. closeOrder(){
  266. this.$refs.addressPop.close();
  267. },
  268. addressChange(data){
  269. if (data.detail) {
  270. this.addressForm.city = JSON.stringify(data.detail.value);
  271. }
  272. },
  273. async getOrder(){
  274. app.loading = true;
  275. var res = await app.$api.order.detail.get({"order":app.optionData.order});
  276. app.loading = false;
  277. if (res.code && res.code == 0) {
  278. app.$dialog.showSuccess(res.msg);
  279. uni.navigateBack()
  280. return ;
  281. }
  282. app.orderData = res.data;
  283. app.getCity()
  284. },
  285. async getCity(){
  286. var resp = await app.$api.home.city.get();
  287. if (resp.code !== 1) return ;
  288. app.cityData = resp.data;
  289. app.fristData.index = 0;
  290. app.fristData.name = resp.data[0].text;
  291. app.fristData.list = resp.data
  292. }
  293. }
  294. }
  295. </script>
  296. <style lang="scss" scoped>
  297. .goods-item-check{
  298. margin: 20rpx;
  299. border: 2rpx solid $main-text-color;
  300. height: 80rpx;
  301. line-height: 80rpx;
  302. text-align: center;
  303. font-size: 28rpx;
  304. color: $main-text-color;
  305. border-radius: 10rpx;
  306. }
  307. .address-pop{
  308. .address-check{
  309. display: flex;
  310. align-items: center;
  311. justify-content: space-around;
  312. color: $main-text-color;
  313. background-color: #f1f1f1;
  314. .check-name{
  315. flex: 1;
  316. text-align: center;
  317. padding: 30rpx 0;
  318. }
  319. }
  320. .address-scroll{
  321. height: 50vh;
  322. overflow: auto;
  323. padding: 20rpx;
  324. .item-name{
  325. padding: 20rpx;
  326. border-bottom: 2rpx solid #f1f1f1;
  327. display: flex;
  328. align-items: center;
  329. justify-content: space-between;
  330. .icon{
  331. display: none;
  332. image {
  333. width: 40rpx;
  334. height: 40rpx;
  335. }
  336. }
  337. &.active{
  338. color: $main-color;
  339. .icon{
  340. display: block;
  341. }
  342. }
  343. }
  344. }
  345. .address-footer{
  346. display: flex;
  347. align-items: center;
  348. justify-content: space-around;
  349. gap: 20rpx;
  350. padding: 20rpx;
  351. .footer-btn{
  352. background-color: #fff;
  353. border: 2rpx solid $main-text-color;
  354. border-radius: 10rpx;
  355. color: $main-text-color;
  356. height: 80rpx;
  357. line-height: 80rpx;
  358. text-align: center;
  359. flex: 1;
  360. &.full{
  361. border: 2rpx solid $main-color;
  362. background-color: $main-color;
  363. color: #fff;
  364. }
  365. }
  366. }
  367. }
  368. .content{
  369. position: fixed;
  370. z-index: 1;
  371. top: 0;
  372. left: 0;
  373. bottom: 0;
  374. right: 0;
  375. background-color: #f1f1f1;
  376. display: flex;
  377. flex-direction: column;
  378. .line-height{
  379. height: 40rpx;
  380. width: 100%;
  381. }
  382. }
  383. .form-feedbak{
  384. background-color: #fff;
  385. border-radius: 20upx;
  386. }
  387. .form-feedbak .title{
  388. line-height: 80upx;
  389. font-size: 28upx;
  390. }
  391. .form-feedbak .title text{
  392. color: #f00;
  393. margin-right: 10upx;
  394. }
  395. .form-feedbak .form-textarea{
  396. background-color: #f8f8f8;
  397. padding: 20upx;
  398. }
  399. .order-body {
  400. width: 95%;
  401. margin: 20rpx auto;
  402. .order-info{
  403. border-radius: 20rpx;
  404. background-color: #fff;padding: 20upx;margin-top: 20upx;
  405. .title-h{
  406. font-size: 32upx;color: #333;font-weight: bold;margin-bottom: 20rpx;
  407. text {
  408. font-size: 28rpx;
  409. color: #666;
  410. font-weight: normal;
  411. margin-left: 20rpx;
  412. }
  413. }
  414. }
  415. .item-goods{
  416. background-color: #fff;
  417. margin-top: 20rpx;
  418. border-radius: 20rpx;
  419. padding: 20rpx;
  420. .item-goods-body{
  421. display: flex;
  422. align-items: center;
  423. gap: 20rpx;
  424. }
  425. .stock{
  426. text-align: right;
  427. }
  428. .image {
  429. height: 140rpx;
  430. overflow: hidden;display: flex;align-items: center;min-width: 140rpx;
  431. position: relative;
  432. image {
  433. width: 140rpx;
  434. border-radius: 10upx;
  435. height: 100%;
  436. }
  437. }
  438. .info{
  439. flex: 1 1 0%;
  440. overflow: hidden;
  441. .title{
  442. display: flex;
  443. align-items: center;
  444. justify-content: space-between;
  445. .name {
  446. overflow: hidden;
  447. text-overflow: ellipsis;
  448. font-size: 32rpx;
  449. display: -webkit-box;
  450. -webkit-line-clamp: 2;
  451. -webkit-box-orient: vertical;
  452. color: #333;
  453. font-weight: 900;
  454. }
  455. }
  456. .price-right{
  457. text-align: right;
  458. color: $main-color;
  459. margin-top: 20rpx;
  460. font-size: 28rpx;
  461. text {
  462. font-size: 30rpx;
  463. font-weight: 800;
  464. }
  465. }
  466. .tags {
  467. color: #94a3b8;
  468. font-size: 24rpx;
  469. margin: 10rpx 0;
  470. display: flex;
  471. align-items: center;
  472. justify-content: space-between;
  473. .price {
  474. font-size: 28rpx;
  475. color: $main-text-color;
  476. font-weight: 600;
  477. }
  478. }
  479. }
  480. }
  481. }
  482. .goods-body{
  483. height: 0;
  484. flex: 1;
  485. }
  486. .footer{
  487. background-color: #fff;
  488. padding: 20upx 20upx 0 20upx;border-top: 2upx solid #f8f8f8;
  489. .footer-safe {
  490. height: env(safe-area-inset-bottom);width: 100%;
  491. }
  492. .footer-op{
  493. display: flex;
  494. align-items: center;
  495. justify-content: space-between;
  496. .footer-right{
  497. display: flex;
  498. align-items: center;
  499. gap: 20rpx;
  500. flex: 1;
  501. .btn{
  502. width: 100%;
  503. font-size: 28rpx;
  504. height: 80upx;
  505. border-radius: 10upx;
  506. line-height: 80upx;
  507. text-align: center;
  508. min-width: 200rpx;
  509. color: #333;
  510. border: 2rpx solid #ccc;
  511. &.full{
  512. background-color: $main-color;
  513. color: #fff;
  514. border: 2rpx solid $main-color;
  515. }
  516. }
  517. }
  518. }
  519. }
  520. </style>