settlement.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <view>
  3. <u-navbar title="结算" :border="true" :placeholder="true" :autoBack="true" leftIconColor="#fff"
  4. bgColor="#E96737" />
  5. <view class="settlement">
  6. <view class="settlement-address">
  7. <view class="flex settlement-address-top">
  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="settlement-address-desc" v-if="info.addr !== null">
  15. <view class="settlement-address-desc__item">{{ `${ addr.province }-${ addr.city }-${ addr.area }` }}
  16. {{ addr.addr }}
  17. </view>
  18. <view class="settlement-address-desc__item">{{ addr.receiver }} {{ addr.mobile }}</view>
  19. </view>
  20. <view class="settlement-address-form" v-else>
  21. <view class="address-add">
  22. <u--form labelPosition="left" ref="form" labelWidth="90">
  23. <u-form-item label="收货人:" borderBottom required>
  24. <u--input v-model="form.receiver" border="none" placeholder="请输入收货人"></u--input>
  25. </u-form-item>
  26. <u-form-item label="手机号码:" borderBottom required>
  27. <u--input v-model="form.mobile" border="none" placeholder="请输入手机号码"></u--input>
  28. </u-form-item>
  29. <u-form-item label="所在地区:" borderBottom required @click="selectArea">
  30. <u--input v-model="form.cityShow" border="none" disabled disabledColor="#ffffff"
  31. placeholder="请选择地区">
  32. </u--input>
  33. <u-icon slot="right" name="arrow-right"></u-icon>
  34. </u-form-item>
  35. <u-form-item label="详细地址:" :borderBottom="false" required>
  36. <u--textarea v-model="form.addr" placeholder="请输入详细地址"></u--textarea>
  37. </u-form-item>
  38. </u--form>
  39. </view>
  40. <!-- 操作按钮 -->
  41. <view class="save-btn">
  42. <button :loading="loading" type="default" @click="saveAddress">保存并使用</button>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="settlement-goods">
  47. <view class="flex settlement-goods__detail" v-for="(item, index) in list" :key="index">
  48. <view class="settlement-goods__detail__left">
  49. <view class="img">
  50. <image class="img" :src="item.picUrl" mode="aspectFill">
  51. </image>
  52. </view>
  53. <view class="info">
  54. <text>{{ item.title }}</text>
  55. <text>面值:{{ $numberFormat(item.facePrice) }}元</text>
  56. <text>规格:{{ item.pkgUnit }}张/包 </text>
  57. </view>
  58. </view>
  59. <view class="settlement-goods__detail__right">
  60. <text>¥{{ $numberFormat(item.pkgSalePrice) }}</text>
  61. <text>x {{ item.orderNum }}</text>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="flex settlement-freight">
  66. <text>运费</text>
  67. <text>¥{{ $numberFormat(info.freightAmt) }}</text>
  68. </view>
  69. </view>
  70. <view class="footer-fixed">
  71. <view class="flex btn">
  72. <view class="btn-left">共计 {{ info.pkgNum }} 包</view>
  73. <view class="btn-right">
  74. <view class="money">
  75. <text>共计:</text>
  76. <text>¥{{ $numberFormat(info.payAmt) }}</text>
  77. </view>
  78. <text class="save" @click="save">提交</text>
  79. </view>
  80. </view>
  81. </view>
  82. <area-picker :area-show="areaShow" @cancel="cancel" @confirmArea="confirmArea" />
  83. </view>
  84. </template>
  85. <script>
  86. import env from '../../config/env.js'
  87. import $http from '@/utils/request.js'
  88. import AreaPicker from '../../components/area-picker/area-picker.vue'
  89. export default {
  90. components:{
  91. AreaPicker
  92. },
  93. data() {
  94. return {
  95. ids: [],
  96. info: {},
  97. addr: {},
  98. list: [],
  99. loading: false,
  100. addrId: '',
  101. form: {
  102. receiver: '',
  103. mobile: '',
  104. name: '',
  105. cityShow: '',
  106. addr: '',
  107. provinceId: '', // 省ID/编码
  108. province: '', // 省
  109. cityId: '', // 市ID/编码
  110. city: '', // 市
  111. areaId: '', // 区ID/编码
  112. area: '', // 区
  113. },
  114. areaShow: false,
  115. toAddressShow: false,
  116. }
  117. },
  118. onLoad(opthios) {
  119. if (opthios.ids) {
  120. this.ids = JSON.parse(opthios.ids)
  121. this.getDetail()
  122. }
  123. if(opthios.boxId) {
  124. this.boxId = opthios.boxId
  125. this.getDetail()
  126. }
  127. },
  128. onShow() {
  129. if (this.toAddressShow) {
  130. this.getDetail()
  131. }
  132. },
  133. methods: {
  134. save() {
  135. $http.post('/api/v1/mp/channel/mall/order/submit', {
  136. memo: ""
  137. }).then(res => {
  138. if (res.code == 0) {
  139. uni.navigateTo({
  140. url:`/pages/order/index?back=1`
  141. })
  142. }
  143. if (res.code == 1016) {
  144. uni.showModal({
  145. title: '提示',
  146. content: '您还未通过经销商认证,请先提交认证。',
  147. success(res) {
  148. if (res.confirm) {
  149. uni.navigateTo({
  150. url: "/pages/attestation/index"
  151. })
  152. }
  153. }
  154. })
  155. }
  156. })
  157. },
  158. getDetail() {
  159. let data = this.ids.length ? {
  160. cartIds: this.ids
  161. } : {
  162. boxId: this.boxId,
  163. orderNum: 1
  164. }
  165. $http.post('/api/v1/mp/channel/mall/order/settle', data).then(res => {
  166. if (res.code == 0) {
  167. this.info = res.data
  168. this.addr = res.data.addr
  169. res.data.items.forEach(item => {
  170. let picUrlArr = item.picUrl.split(',')
  171. item.picUrl = env.filePublic + picUrlArr[0]
  172. })
  173. this.list = res.data.items
  174. }
  175. })
  176. },
  177. getAddrDetail() {
  178. $http.post('/api/v1/mp/channel/mall/addr/query', {
  179. addrId: this.addrId
  180. }).then(res => {
  181. if (res.code == 0) {
  182. let item = res.data
  183. this.form = {
  184. ...item,
  185. cityShow: `${ item.province }-${ item.city }-${ item.area }`
  186. }
  187. }
  188. })
  189. },
  190. selectArea() {
  191. this.areaShow = true
  192. },
  193. confirmArea(obj){
  194. // console.log(obj);
  195. this.form.province = obj.province
  196. this.form.provinceId = obj.provinceId
  197. this.form.city = obj.city
  198. this.form.cityId = obj.cityId
  199. this.form.area = obj.area
  200. this.form.areaId = obj.areaId
  201. this.form.cityShow = obj.cityShow
  202. this.areaShow = false
  203. },
  204. cancel() {
  205. this.areaShow = false
  206. },
  207. toAddress() {
  208. this.toAddressShow = true
  209. uni.navigateTo({
  210. url: "/pages/address/index"
  211. })
  212. },
  213. saveAddress() {
  214. let _this = this
  215. if (!_this.form.receiver) {
  216. uni.$u.toast('请输入收货人');
  217. return
  218. }
  219. if (!_this.form.mobile) {
  220. uni.$u.toast('请输入手机号码');
  221. return
  222. }
  223. const rule = /^[1][0-9][0-9]{9}$/
  224. if (!rule.test(_this.form.mobile)) {
  225. uni.$u.toast('请输入正确的手机号');
  226. return
  227. }
  228. if (!_this.form.cityShow) {
  229. uni.$u.toast('请选择所在地区');
  230. return
  231. }
  232. if (!_this.form.addr) {
  233. uni.$u.toast('请输入详细地址');
  234. return
  235. }
  236. let url = '/api/v1/mp/channel/mall/addr/create'
  237. $http.post(url, this.form).then(res => {
  238. if (res.code == 0) {
  239. uni.$u.toast('保存成功');
  240. this.getDetail()
  241. }
  242. })
  243. },
  244. },
  245. }
  246. </script>
  247. <style lang="scss" scoped>
  248. /deep/ .u-navbar__content__title.u-navbar__content__title {
  249. color: #FFFFFF;
  250. }
  251. </style>
  252. <style lang="scss" scoped>
  253. .settlement {
  254. margin: 10rpx;
  255. padding-bottom: 100rpx;
  256. &-address {
  257. background-color: #fff;
  258. padding: 0 16rpx 24rpx;
  259. margin-bottom: 20rpx;
  260. &-top {
  261. justify-content: space-between;
  262. padding: 24rpx 0;
  263. border-bottom: 1px solid rgba(236, 236, 236, 100);
  264. &__left {
  265. line-height: 40rpx;
  266. }
  267. &__right {
  268. line-height: 40rpx;
  269. color: rgba(35, 126, 212, 100);
  270. }
  271. }
  272. &-desc {
  273. &__item {
  274. line-height: 40rpx;
  275. margin-top: 16rpx;
  276. }
  277. }
  278. &-form {
  279. .save-btn {
  280. padding: 10rpx 20rpx;
  281. /deep/ button {
  282. line-height: 76rpx;
  283. font-size: 28rpx;
  284. height: 76rpx;
  285. color: #fff;
  286. background-color: $uni-bg-color;
  287. border: none;
  288. border-radius: 100rpx;
  289. }
  290. }
  291. }
  292. }
  293. &-goods {
  294. background-color: #fff;
  295. padding: 0 16rpx;
  296. margin-bottom: 20rpx;
  297. &__detail {
  298. padding: 20rpx 0;
  299. justify-content: space-between;
  300. border-bottom: 1px solid rgba(236, 236, 236, 100);
  301. &__left {
  302. display: flex;
  303. height: 170rpx;
  304. .img {
  305. image {
  306. width: 134rpx;
  307. height: 170rpx;
  308. margin-right: 20rpx;
  309. }
  310. }
  311. .info {
  312. display: flex;
  313. flex-direction: column;
  314. justify-content: space-between;
  315. text {
  316. font-size: 24rpx;
  317. color: #9D9D9D;
  318. }
  319. text:first-child {
  320. color: rgba(16, 16, 16, 100);
  321. font-size: 28rpx;
  322. }
  323. }
  324. }
  325. &__right {
  326. display: flex;
  327. height: 170rpx;
  328. flex-direction: column;
  329. justify-content: space-between;
  330. align-items: flex-end;
  331. text:first-child {
  332. font-size: 32rpx;
  333. color: $uni-text-color;
  334. }
  335. }
  336. }
  337. &__detail:last-child {
  338. border: none;
  339. }
  340. }
  341. &-freight {
  342. background-color: #fff;
  343. justify-content: space-between;
  344. padding: 20rpx 16rpx;
  345. }
  346. }
  347. .footer-fixed {
  348. position: fixed;
  349. bottom: var(--window-bottom);
  350. left: 0;
  351. right: 0;
  352. // min-height: 120rpx;
  353. z-index: 11;
  354. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  355. background: #fff;
  356. // margin-bottom: 40rpx;
  357. // 设置ios刘海屏底部横线安全区域
  358. padding-bottom: constant(safe-area-inset-bottom);
  359. padding-bottom: env(safe-area-inset-bottom);
  360. .btn {
  361. justify-content: space-between;
  362. padding: 10rpx 40rpx;
  363. &-right {
  364. display: flex;
  365. align-items: center;
  366. justify-content: flex-end;
  367. .value {
  368. color: $uni-text-color;
  369. }
  370. .save {
  371. width: 190rpx;
  372. height: 60rpx;
  373. line-height: 60rpx;
  374. border-radius: 8rpx;
  375. text-align: center;
  376. margin-left: 40rpx;
  377. background-color: rgba(236, 112, 9, 100);
  378. color: rgba(255, 255, 255, 100);
  379. }
  380. }
  381. }
  382. }
  383. </style>