done.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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. eventChannel:null,
  145. optionData:null,
  146. orderData:null,
  147. loading:false,
  148. cityData:[],
  149. addressForm:{},
  150. isSubmit:false,
  151. addressData:{
  152. name:"请选择",
  153. hide:null,
  154. list:[]
  155. },
  156. fristData:{
  157. index:null,
  158. name:"",
  159. list:[]
  160. },
  161. secondData:{
  162. index:null,
  163. name:"",
  164. list:[]
  165. },
  166. threeData:{
  167. index:null,
  168. name:"",
  169. list:[]
  170. },
  171. doneGoods:[]
  172. }
  173. },
  174. onLoad(options) {
  175. app = this;
  176. app.optionData = options;
  177. app.eventChannel = this.getOpenerEventChannel();
  178. this.getOrder();
  179. },
  180. methods: {
  181. async submitOrder(){
  182. if (app.doneGoods.length == 0) return app.$dialog.showSuccess("请选择意向商品");
  183. var formData = this.addressForm;
  184. var validation = form.validation(formData,[
  185. {name:"nickname",rule:["required"],msg:["请输入姓名"]},
  186. {name:"mobile",rule:["required","isMobile"],msg:["请填写手机号码","手机号码格式错误"]},
  187. {name:"address",rule:["required"],msg:["请输入"]},
  188. ]);
  189. if(validation){
  190. this.$dialog.showSuccess(validation);
  191. return false;
  192. }
  193. if (!app.addressData.hide) return app.$dialog.showSuccess("请选择地区");
  194. formData.goods = JSON.stringify(app.doneGoods);
  195. formData.city = JSON.stringify(app.addressData)
  196. formData.order = app.optionData.order
  197. app.isSubmit = true;
  198. var resp = await app.$api.order.address.post(formData);
  199. app.isSubmit = false;
  200. if (resp.code !== 1) return app.$dialog.showSuccess(resp.msg);
  201. app.$dialog.showSuccess(resp.msg);
  202. app.eventChannel.emit('acceptData', { msg: '会员信息已完善' });
  203. uni.navigateBack();
  204. },
  205. chooseGoods(){
  206. this.$nextTick(()=>{
  207. this.$refs.goodsDialog.open().setData({"order":app.optionData.order,"num":app.orderData.number});
  208. })
  209. },
  210. sendGoods(data){
  211. app.doneGoods = data;
  212. },
  213. checkAddress(){
  214. if (!app.fristData.index) return this.$dialog.showSuccess("请完善地区信息!");
  215. if (!app.secondData.index) return this.$dialog.showSuccess("请完善地区信息~");
  216. if (!app.threeData.index) return this.$dialog.showSuccess("请完善地区信息");
  217. var fristData = app.cityData[app.fristData.index];
  218. var secondData = fristData.children[app.secondData.index];
  219. var threeData = secondData.children[app.threeData.index];
  220. app.addressData.name = fristData.text+"/"+secondData.text+"/"+threeData.text
  221. app.addressData.hide = fristData.text+secondData.text+threeData.text
  222. app.addressData.list = [fristData.value,secondData.value,threeData.value]
  223. app.$refs.addressPop.close()
  224. },
  225. addClick(indx,type) {
  226. if (type == 1) {
  227. app.fristData.index = indx;
  228. app.fristData.list = [];
  229. app.secondData.list = app.cityData[indx].children;
  230. app.fristData.name = app.cityData[indx].text;
  231. }
  232. if (type == 2) {
  233. app.secondData.index = indx;
  234. app.secondData.name = app.secondData.list[indx].text;
  235. app.threeData.list = app.secondData.list[indx].children;
  236. app.secondData.list = [];
  237. }
  238. if (type == 3) {
  239. app.threeData.index = indx;
  240. app.threeData.name = app.threeData.list[indx].text;
  241. }
  242. },
  243. addTop(type,index){
  244. if (type == 1) {
  245. app.fristData.list = app.cityData;
  246. app.secondData.list = [];
  247. app.secondData.index = null;
  248. app.secondData.name = null;
  249. app.threeData.list = [];
  250. app.threeData.index = null;
  251. app.threeData.name = null;
  252. }
  253. if (type == 2) {
  254. app.secondData.list = app.cityData[index].children;
  255. app.threeData.list = [];
  256. app.threeData.index = null;
  257. app.threeData.name = null;
  258. }
  259. },
  260. showAddress(){
  261. this.$refs.addressPop.open();
  262. },
  263. closeOrder(){
  264. this.$refs.addressPop.close();
  265. },
  266. addressChange(data){
  267. if (data.detail) {
  268. this.addressForm.city = JSON.stringify(data.detail.value);
  269. }
  270. },
  271. async getOrder(){
  272. app.loading = true;
  273. var res = await app.$api.order.detail.get({"order":app.optionData.order});
  274. app.loading = false;
  275. if (res.code && res.code == 0) {
  276. app.$dialog.showSuccess(res.msg);
  277. uni.navigateBack()
  278. return ;
  279. }
  280. app.orderData = res.data;
  281. app.getCity()
  282. },
  283. async getCity(){
  284. var resp = await app.$api.home.city.get();
  285. if (resp.code !== 1) return ;
  286. app.cityData = resp.data;
  287. app.fristData.index = 0;
  288. app.fristData.name = resp.data[0].text;
  289. app.fristData.list = resp.data
  290. }
  291. }
  292. }
  293. </script>
  294. <style lang="scss" scoped>
  295. .goods-item-check{
  296. margin: 20rpx;
  297. border: 2rpx solid $main-text-color;
  298. height: 80rpx;
  299. line-height: 80rpx;
  300. text-align: center;
  301. font-size: 28rpx;
  302. color: $main-text-color;
  303. border-radius: 10rpx;
  304. }
  305. .address-pop{
  306. .address-check{
  307. display: flex;
  308. align-items: center;
  309. justify-content: space-around;
  310. color: $main-text-color;
  311. background-color: #f1f1f1;
  312. .check-name{
  313. flex: 1;
  314. text-align: center;
  315. padding: 30rpx 0;
  316. }
  317. }
  318. .address-scroll{
  319. height: 50vh;
  320. overflow: auto;
  321. padding: 20rpx;
  322. .item-name{
  323. padding: 20rpx;
  324. border-bottom: 2rpx solid #f1f1f1;
  325. display: flex;
  326. align-items: center;
  327. justify-content: space-between;
  328. .icon{
  329. display: none;
  330. image {
  331. width: 40rpx;
  332. height: 40rpx;
  333. }
  334. }
  335. &.active{
  336. color: $main-color;
  337. .icon{
  338. display: block;
  339. }
  340. }
  341. }
  342. }
  343. .address-footer{
  344. display: flex;
  345. align-items: center;
  346. justify-content: space-around;
  347. gap: 20rpx;
  348. padding: 20rpx;
  349. .footer-btn{
  350. background-color: #fff;
  351. border: 2rpx solid $main-text-color;
  352. border-radius: 10rpx;
  353. color: $main-text-color;
  354. height: 80rpx;
  355. line-height: 80rpx;
  356. text-align: center;
  357. flex: 1;
  358. &.full{
  359. border: 2rpx solid $main-color;
  360. background-color: $main-color;
  361. color: #fff;
  362. }
  363. }
  364. }
  365. }
  366. .content{
  367. position: fixed;
  368. z-index: 1;
  369. top: 0;
  370. left: 0;
  371. bottom: 0;
  372. right: 0;
  373. background-color: #f1f1f1;
  374. display: flex;
  375. flex-direction: column;
  376. .line-height{
  377. height: 40rpx;
  378. width: 100%;
  379. }
  380. }
  381. .form-feedbak{
  382. background-color: #fff;
  383. border-radius: 20upx;
  384. }
  385. .form-feedbak .title{
  386. line-height: 80upx;
  387. font-size: 28upx;
  388. }
  389. .form-feedbak .title text{
  390. color: #f00;
  391. margin-right: 10upx;
  392. }
  393. .form-feedbak .form-textarea{
  394. background-color: #f8f8f8;
  395. padding: 20upx;
  396. }
  397. .order-body {
  398. width: 95%;
  399. margin: 20rpx auto;
  400. .order-info{
  401. border-radius: 20rpx;
  402. background-color: #fff;padding: 20upx;margin-top: 20upx;
  403. .title-h{
  404. font-size: 32upx;color: #333;font-weight: bold;margin-bottom: 20rpx;
  405. text {
  406. font-size: 28rpx;
  407. color: #666;
  408. font-weight: normal;
  409. margin-left: 20rpx;
  410. }
  411. }
  412. }
  413. .item-goods{
  414. background-color: #fff;
  415. margin-top: 20rpx;
  416. border-radius: 20rpx;
  417. padding: 20rpx;
  418. .item-goods-body{
  419. display: flex;
  420. align-items: center;
  421. gap: 20rpx;
  422. }
  423. .stock{
  424. text-align: right;
  425. }
  426. .image {
  427. height: 140rpx;
  428. overflow: hidden;display: flex;align-items: center;min-width: 140rpx;
  429. position: relative;
  430. image {
  431. width: 140rpx;
  432. border-radius: 10upx;
  433. height: 100%;
  434. }
  435. }
  436. .info{
  437. flex: 1 1 0%;
  438. overflow: hidden;
  439. .title{
  440. display: flex;
  441. align-items: center;
  442. justify-content: space-between;
  443. .name {
  444. overflow: hidden;
  445. text-overflow: ellipsis;
  446. font-size: 32rpx;
  447. display: -webkit-box;
  448. -webkit-line-clamp: 2;
  449. -webkit-box-orient: vertical;
  450. color: #333;
  451. font-weight: 900;
  452. }
  453. }
  454. .price-right{
  455. text-align: right;
  456. color: $main-color;
  457. margin-top: 20rpx;
  458. font-size: 28rpx;
  459. text {
  460. font-size: 30rpx;
  461. font-weight: 800;
  462. }
  463. }
  464. .tags {
  465. color: #94a3b8;
  466. font-size: 24rpx;
  467. margin: 10rpx 0;
  468. display: flex;
  469. align-items: center;
  470. justify-content: space-between;
  471. .price {
  472. font-size: 28rpx;
  473. color: $main-text-color;
  474. font-weight: 600;
  475. }
  476. }
  477. }
  478. }
  479. }
  480. .goods-body{
  481. height: 0;
  482. flex: 1;
  483. }
  484. .footer{
  485. background-color: #fff;
  486. padding: 20upx 20upx 0 20upx;border-top: 2upx solid #f8f8f8;
  487. .footer-safe {
  488. height: env(safe-area-inset-bottom);width: 100%;
  489. }
  490. .footer-op{
  491. display: flex;
  492. align-items: center;
  493. justify-content: space-between;
  494. .footer-right{
  495. display: flex;
  496. align-items: center;
  497. gap: 20rpx;
  498. flex: 1;
  499. .btn{
  500. width: 100%;
  501. font-size: 28rpx;
  502. height: 80upx;
  503. border-radius: 10upx;
  504. line-height: 80upx;
  505. text-align: center;
  506. min-width: 200rpx;
  507. color: #333;
  508. border: 2rpx solid #ccc;
  509. &.full{
  510. background-color: $main-color;
  511. color: #fff;
  512. border: 2rpx solid $main-color;
  513. }
  514. }
  515. }
  516. }
  517. }
  518. </style>