index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <view>
  3. <view class="top">
  4. <image src="../../../static/images/bg.png" mode="widthFix"></image>
  5. <view class="title">无忧快捷发货</view>
  6. </view>
  7. <view class="platform">
  8. <view class="step step1">1.选择数据来源平台</view>
  9. <radio-group @change="changePlatform">
  10. <view class="list">
  11. <view :class="item.id == platformId ? 'item active' : 'item'" v-for="(item,index) in platform" :key="index">
  12. <text :class="'iconfont icon-'+item.code"></text>
  13. {{item.name}}
  14. <radio :value="item.id.toString()" />
  15. </view>
  16. </view>
  17. </radio-group>
  18. </view>
  19. <view class="address">
  20. <view class="step">2.填写收货地址</view>
  21. <view class="form">
  22. <view class="input">
  23. 订单号<input type='text' placeholder='请输入订单号(可不填)' placeholder-class='placeholder' v-model="delivery.out_order_id"></input>
  24. </view>
  25. <view class="input">
  26. 收货人<input type='text' placeholder='请输入收货人姓名' placeholder-class='placeholder' v-model="delivery.name"></input>
  27. </view>
  28. <view class="input">
  29. 手机号<input type='number' placeholder='请输入手机号码' placeholder-class='placeholder' v-model="delivery.mobile"></input>
  30. </view>
  31. <textarea placeholder-style="color:#ccc;font-size:28rpx;" placeholder="示例: 浙江省 台州市 椒江区 市府大道12号" v-model="delivery.address" />
  32. </view>
  33. </view>
  34. <view class="gift">
  35. <view class="step">3.选择赠送礼品</view>
  36. <view class="warehouse">
  37. <view v-for="(item,index) in warehouse" :key="index" :class='item.id == warehouseId ? "on" : ""' @click='changeWarehouse(index)'>
  38. {{item.name}}
  39. </view>
  40. </view>
  41. <radio-group @change="changeProduct" v-if="productList.length > 0">
  42. <view class="product" v-for="(item , index) in productList" :key="index">
  43. <radio :value="index.toString()" />
  44. <image :src="item.img"></image>
  45. <view class="info">
  46. <view>{{item.title}}</view>
  47. <view class="price">¥{{item.price}}</view>
  48. <view class="text">
  49. <view>{{item.wget}}kg/件</view>
  50. <view>库存{{item.count}}</view>
  51. </view>
  52. </view>
  53. </view>
  54. </radio-group>
  55. <view class="noProduct" v-else>暂无产品</view>
  56. </view>
  57. <view class="bottom">
  58. <view>
  59. <view>礼品金额:<text>¥{{price}}</text>,运费:<text>¥{{freight}}</text></view>
  60. <view class="total">总价:<text>¥{{total}}</text></view>
  61. </view>
  62. <button @click="submit">提交订单</button>
  63. </view>
  64. <wyb-popup ref="payOrder" type="bottom" height="500" width="400" radius="8">
  65. <view class="popup">
  66. <view class="title">
  67. 支付订单<text class="iconfont icon-guanbi" @click='close'></text>
  68. </view>
  69. <view>支付单号:{{payData.order_id}}</view>
  70. <view>商品名称:{{payData.title}}</view>
  71. <view>发货数量:{{payData.count}}</view>
  72. <view>支付金额:¥{{payData.all_price}}</view>
  73. <view>支付方式:
  74. <view class="payway">
  75. <text class="iconfont icon-yuezhifu"></text>余额支付
  76. <image src="../../../static/images/icon.png" mode="widthFix"></image>
  77. </view>
  78. <view class="balance">账户余额:¥{{payData.user_money}}<text @click="go">充值</text></view>
  79. </view>
  80. <button @click="pay(payData.order_id)">立即支付</button>
  81. </view>
  82. </wyb-popup>
  83. </view>
  84. </template>
  85. <script>
  86. import {
  87. mapGetters
  88. } from "vuex";
  89. import {
  90. toLogin
  91. } from '@/libs/login.js';
  92. import {
  93. platformList,
  94. ApiWarehouse,
  95. productList,
  96. submitOrder,
  97. payOrder,
  98. balancePay
  99. } from '@/api/api.js';
  100. import wybPopup from '@/components/wyb-popup/wyb-popup.vue'
  101. export default {
  102. components: {
  103. wybPopup
  104. },
  105. data() {
  106. return {
  107. platform: [],
  108. platformId: '',
  109. warehouse: [],
  110. warehouseData: [],
  111. warehouseId: '',
  112. expId: '',
  113. productList: [],
  114. productId: '',
  115. delivery: {
  116. out_order_id: '',
  117. name: '',
  118. mobile: '',
  119. address: '',
  120. shop_name: ''
  121. },
  122. price: 0,
  123. freight: 0,
  124. total: 0,
  125. payData: {}
  126. }
  127. },
  128. computed: mapGetters(['isLogin']),
  129. onLoad() {
  130. if (this.isLogin) {
  131. this.getPlatform();
  132. this.getWarehouse();
  133. this.getProductList();
  134. }else{
  135. toLogin();
  136. }
  137. },
  138. methods: {
  139. getPlatform: function() {
  140. let that = this;
  141. platformList().then(res => {
  142. that.platform = res.data.list;
  143. });
  144. },
  145. getWarehouse: function() {
  146. let that = this;
  147. ApiWarehouse().then(res => {
  148. that.warehouse = res.data;
  149. that.warehouseData = res.data;
  150. });
  151. },
  152. getProductList: function() {
  153. let that = this;
  154. productList({
  155. warehouse: that.warehouseId,
  156. countType: 1,
  157. pageSize: 5
  158. }).then(res => {
  159. that.productList = res.data.list;
  160. });
  161. },
  162. changePlatform:function(evt) {
  163. let that = this;
  164. that.platformId = evt.target.value;
  165. that.tabWarehouse(that.platformId);
  166. that.warehouseId = that.warehouse[0].id;
  167. if(that.warehouse[0].expCode.length > 0){
  168. that.expId = that.warehouse[0].expCode[0].id;
  169. that.freight = parseFloat(that.warehouse[0].expCode[0].money);
  170. that.total = that.price + that.freight;
  171. }
  172. that.getProductList();
  173. },
  174. //选择平台后切换仓库
  175. tabWarehouse:function(id){
  176. var data = [];
  177. //判断仓库
  178. for (var i in this.warehouseData) {
  179. var idsAr = this.warehouseData[i].platform_ids.split(',');
  180. if(idsAr.indexOf(id) >= 0) {
  181. data.push(this.warehouseData[i]);
  182. }
  183. }
  184. this.warehouse = data;
  185. },
  186. changeWarehouse:function(index) {
  187. let that = this;
  188. if (!that.platformId) return that.$util.Tips({
  189. title: '请先选择数据来源平台'
  190. });
  191. that.warehouseId = that.warehouse[index].id;
  192. if(that.warehouse[index].expCode.length > 0){
  193. that.expId = that.warehouse[index].expCode[0].id;
  194. that.freight = parseFloat(that.warehouse[index].expCode[0].money);
  195. that.total = that.price + that.freight;
  196. }else{
  197. that.freight = 0;
  198. that.total = that.price + that.freight;
  199. }
  200. that.getProductList();
  201. },
  202. changeProduct:function(evt) {
  203. let that = this;
  204. if (!that.platformId) return that.$util.Tips({
  205. title: '请先选择数据来源平台'
  206. });
  207. let index = evt.target.value;
  208. that.productId = that.productList[index].id;
  209. that.price = parseFloat(that.productList[index].price);
  210. that.total = that.price + that.freight;
  211. },
  212. submit: function() {
  213. let that = this;
  214. if (!that.platformId) return that.$util.Tips({
  215. title: '请选择数据来源平台'
  216. });
  217. if (!that.delivery.name) return that.$util.Tips({
  218. title: '请输入收货人姓名'
  219. });
  220. if (!that.delivery.mobile) return that.$util.Tips({
  221. title: '请输入手机号码'
  222. });
  223. if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.delivery.mobile))) return that.$util.Tips({
  224. title: '请输入正确的手机号码'
  225. });
  226. if (!that.delivery.address) return that.$util.Tips({
  227. title: '请输入收货地址'
  228. });
  229. if (!that.productId) return that.$util.Tips({
  230. title: '请选择赠送礼品'
  231. });
  232. let orderAr = [];
  233. orderAr.push(that.delivery);
  234. submitOrder({
  235. platformId: that.platformId,
  236. warehouseId: that.warehouseId,
  237. proId: that.productId,
  238. expId: that.expId,
  239. orderAr: orderAr,
  240. mono: ''
  241. }).then(res => {
  242. payOrder({'order_id':res.data.order_id}).then(res => {
  243. that.payData = res.data;
  244. that.$refs.payOrder.show();
  245. });
  246. }).catch(err => {
  247. that.$util.Tips({
  248. title: err
  249. });
  250. });
  251. },
  252. close() {
  253. this.$refs.payOrder.hide();
  254. },
  255. pay: function(order_id) {
  256. let that = this;
  257. balancePay({'order_id':order_id}).then(res => {
  258. that.$util.Tips({
  259. title:res.data.msg
  260. },{
  261. tab: 2,
  262. url: '/pages/users/order/index?status=1'
  263. })
  264. }).catch(err => {
  265. that.$util.Tips({
  266. title: err
  267. });
  268. });
  269. },
  270. go() {
  271. uni.navigateTo({
  272. url: `/pages/users/recharge/index`
  273. })
  274. }
  275. }
  276. }
  277. </script>
  278. <style scoped lang="scss">
  279. .top{
  280. background: #ff5c00;
  281. position: relative;
  282. image{
  283. width:100%;
  284. }
  285. .title{
  286. position: absolute;
  287. top:50rpx;
  288. left:30rpx;
  289. font-size: 46rpx;
  290. color:#fff;
  291. }
  292. }
  293. .step{
  294. font-weight: 600;
  295. color:#262626;
  296. margin-bottom: 20rpx;
  297. }
  298. .platform{
  299. background: #fff;
  300. width:700rpx;
  301. margin: -200rpx 25rpx 0 25rpx;
  302. padding: 30rpx 10rpx;
  303. border-radius: 20rpx;
  304. position: relative;
  305. z-index: 100;
  306. .step1{
  307. padding-left: 10rpx;
  308. }
  309. .list{
  310. display: flex;
  311. flex-wrap: wrap;
  312. .item{
  313. width:320rpx;
  314. margin: 10rpx;
  315. border: 1px solid #ddd;
  316. border-radius: 4rpx;
  317. display: flex;
  318. align-items: center;
  319. padding: 0 15rpx;
  320. line-height: 92rpx;
  321. .iconfont{
  322. font-size: 45rpx;
  323. margin-right: 15rpx;
  324. }
  325. .icon-taobao{color:#FF780A;font-size: 50rpx;}
  326. .icon-t1688{color:#FF5400;font-size: 65rpx;margin-right: 0;}
  327. .icon-jd{color:#E0251B;}
  328. .icon-pdd{color:#E12E24;}
  329. .icon-othen{color:#488EFF;}
  330. radio{
  331. flex-grow:1;
  332. text-align: right;
  333. }
  334. }
  335. .active{
  336. border: 1px solid #ff5c00;
  337. }
  338. }
  339. }
  340. .address{
  341. background: #fff;
  342. width:700rpx;
  343. margin:20rpx 25rpx 0 25rpx;
  344. padding: 30rpx 20rpx;
  345. border-radius: 10rpx;
  346. .form{
  347. .input{
  348. display: flex;
  349. padding: 20rpx 0;
  350. border-bottom: 1px solid #eee;
  351. input{
  352. margin-left: 40rpx;
  353. font-size: 28rpx;
  354. .placeholder{
  355. color:#ccc;
  356. font-size: 28rpx;
  357. }
  358. }
  359. }
  360. textarea{
  361. height:120rpx;
  362. padding-top: 20rpx;
  363. font-size: 28rpx;
  364. }
  365. }
  366. }
  367. .gift{
  368. background: #fff;
  369. width:700rpx;
  370. margin:20rpx 25rpx 140rpx 25rpx;
  371. padding: 30rpx 20rpx;
  372. border-radius: 10rpx;
  373. .warehouse{
  374. display: flex;
  375. flex-wrap: wrap;
  376. margin: 30rpx 0 10rpx 0;
  377. view{
  378. padding: 10rpx 7rpx;
  379. margin-bottom: 10rpx;
  380. border: 1rpx solid #eee;
  381. }
  382. view:nth-child(odd){
  383. margin-right: 10rpx;
  384. }
  385. .on{
  386. border: 1rpx solid #ff5c00;
  387. color: #ff5c00;
  388. }
  389. }
  390. .product{
  391. display: flex;
  392. margin-top: 20rpx;
  393. radio{
  394. line-height: 160rpx;
  395. margin-right: 10rpx;
  396. }
  397. image{
  398. width:160rpx;
  399. height:160rpx;
  400. }
  401. .info{
  402. padding-left: 20rpx;
  403. flex-grow: 1;
  404. .price{
  405. color: #f5222d;
  406. font-size: 32rpx;
  407. font-weight: bold;
  408. margin-top: 40rpx;
  409. }
  410. .text{
  411. display: flex;
  412. justify-content:space-between;
  413. font-size: 24rpx;
  414. color:#666;
  415. }
  416. }
  417. }
  418. .noProduct{
  419. text-align: center;
  420. height:120rpx;
  421. line-height: 120rpx;
  422. }
  423. }
  424. .bottom{
  425. background: #fff;
  426. position: absolute;
  427. bottom: 100rpx;
  428. display: flex;
  429. justify-content: space-between;
  430. align-items: center;
  431. width:100%;
  432. height:120rpx;
  433. padding: 0 32rpx;
  434. text{
  435. color:#ea312b;
  436. }
  437. .total{
  438. display: flex;
  439. align-items: center;
  440. text{
  441. font-size: 36rpx;
  442. font-weight: 600;
  443. }
  444. }
  445. button{
  446. width:220rpx;
  447. height:80rpx;
  448. line-height: 80rpx;
  449. background: #ff5c00;
  450. color:#fff;
  451. font-size: 32rpx;
  452. border-radius: 50rpx;
  453. }
  454. }
  455. .popup{
  456. padding: 30rpx;
  457. view{
  458. display: flex;
  459. align-items: center;
  460. flex-wrap: wrap;
  461. margin-bottom: 10rpx;
  462. }
  463. .title{
  464. justify-content: space-between;
  465. font-size: 32rpx;
  466. margin-bottom: 20rpx;
  467. }
  468. .payway{
  469. display: flex;
  470. position: relative;
  471. border: 1rpx solid #ff5c00;
  472. border-radius: 8rpx;
  473. width: 200rpx;
  474. height: 60rpx;
  475. line-height: 60rpx;
  476. padding-left: 10rpx;
  477. .iconfont{
  478. color:#ff5c00;
  479. margin-right: 5rpx;
  480. }
  481. image{
  482. width:40rpx;
  483. position: absolute;
  484. bottom: 0;
  485. right: 0;
  486. }
  487. }
  488. .balance{
  489. margin-left: 140rpx;
  490. color:#aaa;
  491. text{
  492. border: 1rpx solid #ff5c00;
  493. color:#ff5c00;
  494. margin-left: 30rpx;
  495. padding: 3rpx 20rpx;
  496. border-radius: 30rpx;
  497. }
  498. }
  499. button{
  500. background: #ff5c00;
  501. color:#fff;
  502. border-radius: 40rpx;
  503. font-size: 32rpx;
  504. line-height: 80rpx;
  505. margin-top: 30rpx;
  506. }
  507. }
  508. </style>