index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <view class="flex-col" :style="{height: winHeight + 'px'}">
  3. <!-- #ifdef MP -->
  4. <view class="cart_nav">
  5. <nav-bar iconColor='#fff' ref="navBarRef" navTitle="代取快递" backgroundColor="#FF6702" :isBackgroundColor="false">
  6. </nav-bar>
  7. </view>
  8. <!-- #endif -->
  9. <view class='newsList tui-skeleton flex-col' style="background-color: #fff;flex: 1;">
  10. <view class='nav'>
  11. <scroll-view class="scroll-view_x" scroll-x scroll-with-animation :scroll-left="scrollLeft" style="width:auto;overflow:hidden;">
  12. <block v-for="(item,index) in navList" :key="index">
  13. <view class='item borRadius14 tui-skeleton-rect' :class='active==item.id?"on":""' @click='tabSelect(item.id, index)'>
  14. <view class="line1">{{item.name}}</view>
  15. <view class='line bg_color' v-if="active==item.id"></view>
  16. </view>
  17. </block>
  18. </scroll-view>
  19. </view>
  20. <view class='list' style="flex: 1;">
  21. <template v-if="active == 1">
  22. <take-fast-mail ref="takeFastMailRef" :addressObj="addressItem" :addressExpressObj="addressExpressItem"></take-fast-mail>
  23. </template>
  24. <template v-if="active == 2">
  25. <send-fast-mail></send-fast-mail>
  26. </template>
  27. </view>
  28. <!-- 购物车栏 begin -->
  29. <view class="cart-box">
  30. <view class="mark-box">
  31. <view class="mark">应付 ¥ <text style="font-size: 31rpx;">{{orderPrice}}</text></view>
  32. <view class="tips">普通用户 | 查看明细 》</view>
  33. </view>
  34. <button type="primary" class="pay-btn" @tap="toPay">
  35. 提交订单
  36. </button>
  37. </view>
  38. </view>
  39. <fast-mail-order v-if="isOrder" @onCancel="onCanCel"></fast-mail-order>
  40. </view>
  41. </template>
  42. <script>
  43. // +----------------------------------------------------------------------
  44. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  45. // +----------------------------------------------------------------------
  46. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  47. // +----------------------------------------------------------------------
  48. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  49. // +----------------------------------------------------------------------
  50. // | Author: CRMEB Team <admin@crmeb.com>
  51. // +----------------------------------------------------------------------
  52. import navBar from '@/components/navBar';
  53. import animationType from '@/utils/animationType.js'
  54. import tuiSkeleton from '@/components/base/tui-skeleton.vue';
  55. import sendFastMail from '../components/send_fast_mail/index.vue'
  56. import takeFastMail from '../components/take_fast_mail/index.vue'
  57. import fastMailOrder from '../components/fast_mail_order/index.vue'
  58. import {
  59. getAddressDefault,
  60. getAddressExpressDefault
  61. } from '@/api/user.js';
  62. import {
  63. preExpressApi
  64. } from '@/api/fastMail.js';
  65. let app = getApp();
  66. export default {
  67. components: {
  68. tuiSkeleton,
  69. navBar,
  70. sendFastMail,
  71. takeFastMail,
  72. fastMailOrder
  73. },
  74. data() {
  75. return {
  76. isOrder: false,
  77. winHeight: 0,
  78. isNodes: 0, //控制什么时候开始抓取元素节点,只要数值改变就重新抓取
  79. autoplay: true,
  80. navList: [{
  81. id: 1,
  82. name: '取快递',
  83. preOrderType: 'take'
  84. }, {
  85. id: 2,
  86. name: '寄快递',
  87. preOrderType: 'send'
  88. }],
  89. navListIndex: 0,
  90. active: 1,
  91. scrollLeft: 0,
  92. addressItem: {},
  93. orderPrice: 0,
  94. addressExpressItem: {}
  95. };
  96. },
  97. onLoad() {
  98. let that = this;
  99. uni.getSystemInfo({
  100. success: function(res) {
  101. that.winHeight = res.windowHeight
  102. },
  103. });
  104. this.getaddressInfo()
  105. },
  106. /**
  107. * 生命周期函数--监听页面显示
  108. */
  109. onShow: function() {
  110. let that = this;
  111. uni.$on('addressItem', function(res) {
  112. that.$set(that, 'addressItem', res);
  113. })
  114. uni.$on('addressExpressItem', function(res) {
  115. that.$set(that, 'addressExpressItem', res);
  116. })
  117. },
  118. methods: {
  119. tabSelect(active, e) {
  120. this.active = active;
  121. this.navListIndex = e;
  122. this.scrollLeft = e * 60;
  123. },
  124. /*
  125. * 获取默认收货地址或者获取某条地址信息
  126. */
  127. getaddressInfo: function() {
  128. getAddressDefault().then(res => {
  129. console.log('地址', res)
  130. this.addressItem = res.data || {}
  131. })
  132. getAddressExpressDefault().then(res => {
  133. console.log('驿站地址', res)
  134. this.addressExpressItem = res.data || {}
  135. })
  136. },
  137. toPay() {
  138. const refTake = this.$refs.takeFastMailRef;
  139. // uni.showLoading({
  140. // title: '保存中',
  141. // mask: true
  142. // })
  143. this.orderPrice = +(refTake.fastMailObj.giveTips || 0) + +refTake.fastMailObj?.sepec?.fee || 0
  144. let value = {
  145. giveTips: refTake.fastMailObj.giveTips,
  146. orderDetails: [{
  147. expressInfo: refTake.fastMailObj.expressInfo || '',
  148. expressNum: 1,
  149. image: refTake.fastMailObj.figureArr ? refTake.fastMailObj.figureArr[0] : '',
  150. orderNo: "",
  151. price: this.orderPrice || 0,
  152. remark: refTake.fastMailObj.remark || '',
  153. sepec: +refTake.fastMailObj?.sepec?.fee || 0
  154. }],
  155. postAddressId: refTake.addressExpressObj.id,
  156. preOrderType: this.navList[this.navListIndex].preOrderType,
  157. userAddressId: refTake.addressObj.id
  158. }
  159. const tips = this.checkData(value)
  160. if (tips) {
  161. return this.$util.Tips({
  162. title: tips
  163. });
  164. }
  165. preExpressApi(value).then(res => {
  166. this.isOrder = true;
  167. console.log(res)
  168. // uni.hideLoading();
  169. }).catch(err => {
  170. uni.showToast({
  171. title: err,
  172. icon: 'none'
  173. })
  174. })
  175. console.log(value)
  176. },
  177. onCanCel(val) {
  178. this.isOrder = val
  179. },
  180. checkData(val) {
  181. if (!val.postAddressId) return '请填写取件地'
  182. if (!val.userAddressId) return '请填写收件人信息'
  183. if (!val.orderDetails[0].sepec) return '快递规格必选'
  184. if (!val.orderDetails[0].expressInfo) return '请填写快递信息'
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="scss">
  190. .courie {
  191. padding: 14rpx 24rpx 0 24rpx;
  192. font-weight: 500;
  193. font-size: 23rpx;
  194. color: $bg-color-primary;
  195. background-color: #fff;
  196. image {
  197. width: 46rpx;
  198. height: 46rpx;
  199. margin-right: 15rpx;
  200. }
  201. }
  202. .newsList .swiper {
  203. width: 100%;
  204. position: relative;
  205. box-sizing: border-box;
  206. padding: 0 30rpx;
  207. }
  208. .newsList .swiper swiper {
  209. width: 100%;
  210. height: 365rpx;
  211. position: relative;
  212. }
  213. .newsList .swiper .slide-image {
  214. width: 100%;
  215. height: 335rpx;
  216. border-radius: 14rpx;
  217. }
  218. // #ifdef MP-WEIXIN
  219. .newsList .swiper .wx-swiper-dot {
  220. width: 12rpx !important;
  221. height: 12rpx !important;
  222. border-radius: 0;
  223. transform: rotate(-45deg);
  224. transform-origin: 0 100%;
  225. }
  226. .newsList .swiper .wx-swiper-dot~.wx-swiper-dot {
  227. margin-left: 5rpx;
  228. }
  229. .newsList .swiper .wx-swiper-dots.wx-swiper-dots-horizontal {
  230. margin-bottom: -15rpx;
  231. }
  232. // #endif
  233. // #ifdef APP-PLUS || H5
  234. .newsList .swiper .uni-swiper-dot {
  235. width: 12rpx !important;
  236. height: 12rpx !important;
  237. border-radius: 0;
  238. transform: rotate(-45deg);
  239. transform-origin: 0 100%;
  240. }
  241. .newsList .swiper .uni-swiper-dot~.uni-swiper-dot {
  242. margin-left: 5rpx;
  243. }
  244. .newsList .swiper .uni-swiper-dots.uni-swiper-dots-horizontal {
  245. margin-bottom: -15rpx;
  246. }
  247. // #endif
  248. .newsList .nav {
  249. padding: 0 24rpx;
  250. width: 100%;
  251. white-space: nowrap;
  252. box-sizing: border-box;
  253. padding-top: 43rpx;
  254. border-top-right-radius: 23rpx;
  255. }
  256. .newsList .nav .item {
  257. // max-width: 156rpx;
  258. display: inline-block;
  259. font-size: 32rpx;
  260. color: #999;
  261. }
  262. .newsList .nav .item.on {
  263. color: #282828;
  264. }
  265. .newsList .nav .item~.item {
  266. margin-left: 46rpx;
  267. }
  268. .newsList .nav .item .line {
  269. // width: 24rpx;
  270. height: 10rpx;
  271. border-radius: 6rpx;
  272. margin: 10rpx auto 0 auto;
  273. background-color: $bg-color-primary;
  274. }
  275. .newsList .nav .item .line1 {
  276. color: $bg-color-primary;
  277. }
  278. .cart-box {
  279. height: 96rpx;
  280. border-radius: 48rpx;
  281. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.2);
  282. background-color: #000;
  283. display: flex;
  284. align-items: center;
  285. justify-content: space-between;
  286. z-index: 9999;
  287. .pay-btn {
  288. height: 100%;
  289. padding: 0 30rpx;
  290. color: #FFFFFF;
  291. border-radius: 0 50rpx 50rpx 0;
  292. display: flex;
  293. align-items: center;
  294. font-size: $font-size-base;
  295. background-color: $bg-color-primary;
  296. }
  297. .mark-box {
  298. padding-left: 46rpx;
  299. margin-right: 30rpx;
  300. position: relative;
  301. .mark {
  302. font-weight: 500;
  303. font-size: 23rpx;
  304. color: #FFFFFF;
  305. }
  306. .tips {
  307. font-weight: 500;
  308. font-size: 27rpx;
  309. color: #999999;
  310. }
  311. }
  312. }
  313. </style>