settlement.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. <template>
  2. <view>
  3. <u-navbar title="提交订单" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
  4. <view class="settlement">
  5. <view class="settlement-address">
  6. <!-- 选择地址、获取微信地址 -->
  7. <view class="flex settlement-address-top" v-if="info.addr !== null">
  8. <view class="settlement-address-top__left">配送地址</view>
  9. <view class="flex settlement-address-top__right" @click="toAddress">
  10. <view class="">更改地址</view>
  11. <u-icon name="arrow-right" size="18" color="#237ED4 100%"></u-icon>
  12. </view>
  13. </view>
  14. <view class="flex settlement-address-top" v-else>
  15. <view class="settlement-address-top__left">配送地址</view>
  16. <view class="flex settlement-address-top__right" @click="toWeixinAddress">
  17. <view class="">微信地址</view>
  18. <u-icon name="arrow-right" size="18" color="#237ED4 100%"></u-icon>
  19. </view>
  20. </view>
  21. <!-- 收货人、地址 -->
  22. <view class="settlement-address-desc" v-if="info.addr !== null">
  23. <view class="settlement-address-desc__item">{{ addr.receiver || '-' }}<text>{{ addr.mobile || '-' }}</text></view>
  24. <view class="settlement-address-desc__item">
  25. {{ `${ addr.province || '-' } ${ addr.city || '-' } ${ addr.area || '-' }` }} {{ addr.addr || '-' }}</view>
  26. </view>
  27. <!-- 地址form -->
  28. <view class="settlement-address-form" v-else>
  29. <view class="address-add">
  30. <u--form labelPosition="left" ref="form" labelWidth="90">
  31. <u-form-item label="收货人:" borderBottom required>
  32. <u--input v-model="form.receiver" border="none" placeholder="请输入收货人"></u--input>
  33. </u-form-item>
  34. <u-form-item label="手机号码:" borderBottom required>
  35. <u--input v-model="form.mobile" border="none" placeholder="请输入手机号码"></u--input>
  36. </u-form-item>
  37. <u-form-item label="所在地区:" borderBottom required @click="selectArea">
  38. <u--input v-model="form.cityShow" border="none" disabled disabledColor="#ffffff"
  39. placeholder="请选择地区">
  40. </u--input>
  41. <u-icon slot="right" name="arrow-right"></u-icon>
  42. </u-form-item>
  43. <u-form-item label="详细地址:" :borderBottom="false" required>
  44. <u--textarea v-model="form.addr" placeholder="请输入详细地址"></u--textarea>
  45. </u-form-item>
  46. </u--form>
  47. </view>
  48. <!-- 操作按钮 -->
  49. <view class="save-btn">
  50. <button :loading="loading" type="default" @click="saveAddress">保存并使用</button>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 商品 -->
  55. <view class="settlement-goods">
  56. <view class="settlement-goods-item" v-for="(item, index) in list" :key="index">
  57. <image :src="item.picUrl" mode="aspectFit"></image>
  58. <view class="info">
  59. <view class="info-title ells">{{ item.title }}</view>
  60. <view class="info-num flex">
  61. <view class="info-num-sku ells-one">规格:{{ item.properties || '-' }}</view>
  62. <view class="info-num-goods">数量:{{ item.goodsNum }}</view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="settlement-freight flex">
  68. <text>留言</text>
  69. <u-input v-model="info.memo" placeholder="请输入留言" clearable inputAlign="right" border="none" />
  70. </view>
  71. <view class="settlement-freight flex">
  72. <text>运费</text>
  73. <text>¥{{ $numberFormat(info.freightAmt) }}</text>
  74. </view>
  75. <view class="settlement-tip">
  76. <view class="settlement-tip-title">尊敬的用户您好!</view>
  77. <view class="settlement-tip-content">您提交的商品订单将会在第一时间为您处理,正常产品都会在48小时内发货,由于因疫情原因可能导致到货时间延后,我们深表歉意,有任何问题可以点击“我的”一“联系我们”,或者关注盲票公众号联系我们。</view>
  78. </view>
  79. </view>
  80. <view class="footer-fixed">
  81. <view class="content">
  82. <view class="content-not flex" v-if="info.freightType == 2">
  83. <icon type="warn" color="#F9832E" style="vertical-align: bottom; margin-right: 20rpx; " size="20"/>
  84. <text>当前收货地址暂不支持发货</text>
  85. </view>
  86. <view class="content-btn flex">
  87. <view class="content-btn-left">
  88. <view class="money">
  89. <text>合计:</text>
  90. <text class="value">¥{{ $numberFormat(info.payAmt) }}</text>
  91. </view>
  92. </view>
  93. <view class="content-btn-right">
  94. <text class="save not" v-if="info.freightType == 2">提交</text>
  95. <text class="save" @click="save" v-else>提交</text>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <area-picker :area-show="areaShow" @cancel="cancel" @confirmArea="confirmArea" />
  101. <auth :auth-show="authShow" @close="authShow = false" />
  102. </view>
  103. </template>
  104. <script>
  105. import env from '../../config/env.js'
  106. import $http from '@/utils/request.js'
  107. import AreaPicker from '../../components/area-picker/area-picker.vue'
  108. import Auth from '../../components/auth/auth.vue'
  109. export default {
  110. components: {
  111. AreaPicker,
  112. Auth
  113. },
  114. data() {
  115. return {
  116. ids: [],
  117. info: {},
  118. addr: {},
  119. list: [],
  120. loading: false,
  121. addrId: '',
  122. form: {
  123. receiver: '',
  124. mobile: '',
  125. name: '',
  126. cityShow: '',
  127. addr: '',
  128. provinceId: '', // 省ID/编码
  129. province: '', // 省
  130. cityId: '', // 市ID/编码
  131. city: '', // 市
  132. areaId: '', // 区ID/编码
  133. area: '', // 区
  134. },
  135. areaShow: false,
  136. toAddressShow: false,
  137. wxAddress: {},
  138. payment: '',
  139. authShow: false,
  140. }
  141. },
  142. onLoad(opthios) {
  143. if (opthios.ids) {
  144. this.ids = JSON.parse(opthios.ids)
  145. this.getDetail()
  146. }
  147. if(opthios.goodsId){
  148. this.payment = {
  149. goodsId:opthios.goodsId,
  150. skuId:opthios.skuId,
  151. num:opthios.num,
  152. resource:2,
  153. }
  154. this.getDetail()
  155. }
  156. },
  157. onShow() {
  158. if (this.toAddressShow) {
  159. this.getDetail()
  160. }
  161. },
  162. methods: {
  163. save() {
  164. if (this.info.addr == null) {
  165. uni.$u.toast('请先保存配送地址');
  166. return
  167. }
  168. let _this = this
  169. let payIng = false
  170. if (payIng) return
  171. uni.showLoading({
  172. title: '加载中'
  173. });
  174. $http.post('/api/v1/mp/user/deliver/order/submit', {memo:this.info.memo}).then(res => {
  175. payIng = true
  176. uni.hideLoading();
  177. if (res.code == 0) {
  178. if (res.data.needPay == 1) {
  179. $http.post('/api/v1/mp/user/deliver/order/pay', {
  180. orderId: res.data.orderId,
  181. payType: 2
  182. }).then(ele => {
  183. if (ele.code == 0) {
  184. uni.requestPayment({
  185. timeStamp: ele.data.timeStamp,
  186. nonceStr: ele.data.nonceStr,
  187. package: ele.data.package,
  188. signType: ele.data.signType,
  189. paySign: ele.data.paySign,
  190. success() {
  191. uni.showToast({
  192. title: '支付成功',
  193. icon: 'success',
  194. duration: 2000
  195. })
  196. setTimeout(() => {
  197. uni.redirectTo({
  198. url: `/packageGoods/order/index`
  199. })
  200. }, 500)
  201. },
  202. fail() {
  203. payIng = false
  204. setTimeout(() => {
  205. uni.redirectTo({
  206. url: `/packageGoods/order/index`
  207. })
  208. }, 500)
  209. }
  210. })
  211. } else if (ele.code == 1005) {
  212. _this.authShow = true
  213. } else {
  214. payIng = false
  215. uni.$u.toast('支付失败!');
  216. setTimeout(() => {
  217. uni.redirectTo({
  218. url: `/packageGoods/order/index`
  219. })
  220. }, 500)
  221. }
  222. }).catch(() => {
  223. payIng = false
  224. uni.$u.toast('支付失败!');
  225. setTimeout(() => {
  226. uni.redirectTo({
  227. url: `/packageGoods/order/index`
  228. })
  229. }, 500)
  230. })
  231. } else {
  232. uni.showToast({
  233. title: '提交成功',
  234. icon: 'success',
  235. duration: 2000
  236. })
  237. setTimeout(() => {
  238. uni.redirectTo({
  239. url: `/packageGoods/order/index`
  240. })
  241. }, 500)
  242. }
  243. } else {
  244. payIng = false
  245. uni.$u.toast('提交失败!');
  246. }
  247. }).catch(() => {
  248. payIng = false
  249. uni.$u.toast('提交失败!');
  250. uni.hideLoading();
  251. })
  252. },
  253. getDetail() {
  254. uni.showLoading({
  255. title: '加载中'
  256. });
  257. let data = {
  258. ids: this.ids
  259. }
  260. if(this.payment != ""){
  261. data = this.payment
  262. }
  263. $http.post('/api/v1/mp/user/deliver/order/settle', data ).then(res => {
  264. uni.hideLoading();
  265. if (res.code == 0) {
  266. this.info = res.data
  267. this.addr = res.data.addr
  268. res.data.prizeList.forEach(item => {
  269. let picUrlArr = item.picUrl.split(',')
  270. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
  271. })
  272. this.list = res.data.prizeList
  273. }
  274. }).catch(() => {
  275. uni.hideLoading();
  276. })
  277. },
  278. selectArea() {
  279. this.areaShow = true
  280. },
  281. confirmArea(obj) {
  282. this.form.province = obj.province
  283. this.form.provinceId = obj.provinceId
  284. this.form.city = obj.city
  285. this.form.cityId = obj.cityId
  286. this.form.area = obj.area
  287. this.form.areaId = obj.areaId
  288. this.form.cityShow = obj.cityShow
  289. this.areaShow = false
  290. },
  291. cancel() {
  292. this.areaShow = false
  293. },
  294. toAddress() {
  295. this.toAddressShow = true
  296. uni.navigateTo({
  297. url: "/packageOperate/address/index"
  298. })
  299. },
  300. toWeixinAddress() {
  301. let _this = this
  302. uni.chooseAddress({
  303. success(res) {
  304. _this.wxAddress = res
  305. _this.getArea()
  306. }
  307. })
  308. },
  309. // 回显微信地址
  310. async getArea() {
  311. // 获取省
  312. let provinceRes = await $http.post('/api/v1/mp/area/listByPid', {
  313. pid: 0
  314. })
  315. let provinceItem = provinceRes && provinceRes.data.find((item=> item.areaName == this.wxAddress.provinceName))
  316. // 获取市
  317. let cityRes = await $http.post('/api/v1/mp/area/listByPid', {
  318. pid: provinceItem && provinceItem.areaId
  319. })
  320. let cityItem = cityRes && cityRes.data.find((item=> item.areaName == this.wxAddress.cityName))
  321. // 获取区
  322. let areaRes = await $http.post('/api/v1/mp/area/listByPid', {
  323. pid: cityItem && cityItem.areaId
  324. })
  325. let areaItem = areaRes && areaRes.data.find((item=> item.areaName == this.wxAddress.countyName))
  326. // 赋值
  327. this.form.province = provinceItem.areaName
  328. this.form.provinceId = provinceItem.areaId
  329. this.form.city = cityItem.areaName
  330. this.form.cityId = cityItem.areaId
  331. this.form.area = areaItem.areaName
  332. this.form.areaId = areaItem.areaId
  333. this.form.cityShow = `${ provinceItem.areaName }-${ cityItem.areaName }-${ areaItem.areaName }`
  334. this.form.addr = this.wxAddress.detailInfo
  335. this.form.receiver = this.wxAddress.userName
  336. this.form.mobile = this.wxAddress.telNumber
  337. },
  338. saveAddress() {
  339. let _this = this
  340. if (!_this.form.receiver) {
  341. uni.$u.toast('请输入收货人');
  342. return
  343. }
  344. if (!_this.form.mobile) {
  345. uni.$u.toast('请输入手机号码');
  346. return
  347. }
  348. const rule = /^[1][0-9][0-9]{9}$/
  349. if (!rule.test(_this.form.mobile)) {
  350. uni.$u.toast('请输入正确的手机号');
  351. return
  352. }
  353. if (!_this.form.cityShow) {
  354. uni.$u.toast('请选择所在地区');
  355. return
  356. }
  357. if (!_this.form.addr) {
  358. uni.$u.toast('请输入详细地址');
  359. return
  360. }
  361. let url = '/api/v1/mp/user/addr/create'
  362. $http.post(url, this.form).then(res => {
  363. if (res.code == 0) {
  364. uni.$u.toast('保存成功');
  365. this.getDetail()
  366. }
  367. })
  368. },
  369. },
  370. }
  371. </script>
  372. <style lang="scss" scoped>
  373. .settlement {
  374. margin: 34rpx;
  375. padding-bottom: 100rpx;
  376. &-address {
  377. background-color: #fff;
  378. padding: 34rpx;
  379. margin-bottom: 34rpx;
  380. border-radius: 22rpx;
  381. // 选择地址、获取微信地址
  382. &-top {
  383. justify-content: space-between;
  384. padding: 0 0 34rpx;
  385. border-bottom: 1px solid rgba(236, 236, 236, 100);
  386. &__left {
  387. line-height: 40rpx;
  388. }
  389. &__right {
  390. line-height: 40rpx;
  391. color: rgba(35, 126, 212, 100);
  392. }
  393. }
  394. // 收货人、地址
  395. &-desc {
  396. margin-top: 34rpx;
  397. &__item {
  398. line-height: 28rpx;
  399. margin-bottom: 20rpx;
  400. text {
  401. padding-left: 8rpx;
  402. font-size: 24rpx;
  403. color: #666;
  404. }
  405. }
  406. &__item:last-child {
  407. margin-bottom: 0;
  408. color: #999;
  409. }
  410. }
  411. // 地址form
  412. &-form {
  413. .save-btn {
  414. padding: 10rpx 20rpx;
  415. /deep/ button {
  416. line-height: 76rpx;
  417. font-size: 28rpx;
  418. height: 76rpx;
  419. color: #fff;
  420. background-color: $uni-bg-color;
  421. border: none;
  422. border-radius: 100rpx;
  423. }
  424. }
  425. }
  426. }
  427. // 商品
  428. &-goods {
  429. // 商品列表
  430. &-item{
  431. display: flex;
  432. padding: 34rpx 32rpx 34rpx 22rpx;
  433. box-shadow: 0px 0px 8px 0px rgba(26, 35, 113, 0.08);
  434. background-color: #fff;
  435. border-radius: 22rpx;
  436. margin-bottom: 34rpx;
  437. image {
  438. width: 176rpx;
  439. height: 176rpx;
  440. border-radius: 12rpx;
  441. margin-right: 22rpx;
  442. }
  443. .info {
  444. display: flex;
  445. flex-direction: column;
  446. justify-content: space-between;
  447. flex: 1;
  448. padding: 8rpx 0;
  449. &-title {
  450. font-size: 30rpx;
  451. font-weight: bold;
  452. line-height: 40rpx;
  453. }
  454. &-num {
  455. justify-content: space-between;
  456. &-sku {
  457. flex: 1;
  458. color: #666666;
  459. font-size: 26rpx;
  460. }
  461. &-goods {
  462. color: #666666;
  463. font-size: 26rpx;
  464. }
  465. }
  466. }
  467. }
  468. }
  469. // 留言、运费
  470. &-freight {
  471. font-size: 30rpx;
  472. margin-bottom: 34rpx;
  473. background-color: #fff;
  474. justify-content: space-between;
  475. padding: 34rpx;
  476. border-radius: 22rpx;
  477. }
  478. // 留言、运费
  479. &-tip {
  480. font-size: 30rpx;
  481. margin-bottom: 34rpx;
  482. background-color: #fff;
  483. justify-content: space-between;
  484. padding: 34rpx;
  485. border-radius: 22rpx;
  486. &-title {
  487. font-size: 26rpx;
  488. line-height: 24rpx;
  489. margin-bottom: 24rpx;
  490. }
  491. &-content {
  492. font-size: 24rpx;
  493. line-height: 40rpx;
  494. }
  495. }
  496. }
  497. .footer-fixed {
  498. position: fixed;
  499. bottom: var(--window-bottom);
  500. left: 0;
  501. right: 0;
  502. z-index: 11;
  503. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  504. background: #fff;
  505. // 设置ios刘海屏底部横线安全区域
  506. padding-bottom: constant(safe-area-inset-bottom);
  507. padding-bottom: env(safe-area-inset-bottom);
  508. .content {
  509. padding: 20rpx 0;
  510. font-size: 30rpx;
  511. // 不发货提示
  512. &-not {
  513. justify-content: flex-start;
  514. font-size: 30rpx;
  515. color: #F9832E;
  516. margin: 0 0 30rpx;
  517. padding: 0 40rpx 24rpx;
  518. border-bottom: 1px solid #eee;
  519. }
  520. // 提交按钮
  521. &-btn {
  522. justify-content: space-between;
  523. padding: 0 40rpx;
  524. &-left {
  525. .value {
  526. color: #FF4208;
  527. }
  528. }
  529. &-right {
  530. display: flex;
  531. align-items: center;
  532. justify-content: flex-end;
  533. .save {
  534. width: 210rpx;
  535. height: 82rpx;
  536. line-height: 82rpx;
  537. background: #F9822C;
  538. border-radius: 40rpx;
  539. text-align: center;
  540. color: #fff;
  541. }
  542. .not {
  543. background-color: #6c6c6c;
  544. }
  545. }
  546. }
  547. }
  548. }
  549. </style>