orders.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <template>
  2. <view class="bagStorageOrders">
  3. <navigation-bar-view ref="nav" :maxTimer="60"></navigation-bar-view>
  4. <view class="label-box">第一步:选择箱门</view>
  5. <view class="selected-box">
  6. <block v-for="(item, i) in rentCabinetList" :key="i">
  7. <view class="item" :class="selectedIndex == i ? 'active' : ''" @click="changeSpec(i)">
  8. <image class="selected-icon" :src="require('../../static/images/icon-selected.png')" v-if="selectedIndex == i"></image>
  9. <block v-if="item.cabinetType == 1">
  10. <image class="small-icon" :src="require('../../static/images/icon-sub-box-selected.png')" v-if="selectedIndex == i"></image>
  11. <image class="small-icon" :src="require('../../static/images/icon-sub-box.png')" v-else></image>
  12. <view class="label">小格子</view>
  13. </block>
  14. <block v-if="item.cabinetType == 2">
  15. <image class="middle-icon" :src="require('../../static/images/icon-middle-box-selected.png')" v-if="selectedIndex == i"></image>
  16. <image class="middle-icon" :src="require('../../static/images/icon-middle-box.png')" v-else></image>
  17. <view class="label">中格子</view>
  18. </block>
  19. <block v-if="item.cabinetType == 3">
  20. <image class="big-icon" :src="require('../../static/images/icon-big-box-selected.png')" v-if="selectedIndex == i"></image>
  21. <image class="big-icon" :src="require('../../static/images/icon-big-box.png')" v-else></image>
  22. <view class="label">大格子</view>
  23. </block>
  24. <view class="message">{{item.cabinetDesc}}</view>
  25. </view>
  26. </block>
  27. </view>
  28. <view class="label-box">第二步:存物人手机号</view>
  29. <view class="input-box">{{options.phone}}</view>
  30. <view class="label-box">第三步:选择存放时长</view>
  31. <picker mode="selector" :range="rentOptionDtoList" range-key="name" :value="timersIndex" @change="changeTimers">
  32. <view class="input-box selected">
  33. <text v-if="rentOptionDtoList.length">{{rentOptionDtoList[timersIndex].name}}</text>
  34. <image class="arrow" :src="require('../../static/images/icon-arrow-right-grey.png')"></image>
  35. </view>
  36. </picker>
  37. <view class="agreement-box">
  38. <text>下单即同意</text>
  39. <text class="agreement" @click="openAgreementPopup">《木桩租柜服务用户协议》</text>
  40. </view>
  41. <view class="footer-btn">
  42. <view class="left">
  43. <view class="price" v-if="rentCabinetList.length">¥{{rentCabinetList[selectedIndex].price}}</view>
  44. <!-- -->
  45. <!-- <view class="message" @click="showPriceDetail">
  46. <text>查看价格详情</text>
  47. <image class="arrow" :src="require('../../static/images/icon-arrow-right-grey.png')"></image>
  48. </view> -->
  49. </view>
  50. <view class="right" @click="orders">下单</view>
  51. </view>
  52. <uni-popup ref="agreementPopup" type="center">
  53. <view class="agreement-popup">
  54. <image class="delete-icon" :src="require('../../static/images/icon-delete.png')" @click="closeAgreementPopup"></image>
  55. <scroll-view class="text-box" scroll-y>
  56. <rich-text :nodes="agreement.data"></rich-text>
  57. </scroll-view>
  58. </view>
  59. </uni-popup>
  60. <uni-popup ref="priceDetailPopup" type="center">
  61. <view class="price-popup">
  62. <image class="delete-icon" src="../../static/images/icon-delete.png" @click="closePriceDetail"></image>
  63. <view class="title">
  64. <text>存包费用:</text>
  65. <text class="num">3</text>
  66. <text>元</text>
  67. </view>
  68. <view class="label">详细价格详情</view>
  69. <block v-for="(item, i) in rentPopup" :key="i">
  70. <view class="cell">
  71. <image class="icon" :src="require('../../static/images/icon-sub-box-popup.png')" mode="aspectFit" v-if="item.cabinetType == 1"></image>
  72. <image class="icon" :src="require('../../static/images/icon-middle-box-popup.png')" mode="aspectFit" v-if="item.cabinetType == 2"></image>
  73. <image class="icon" :src="require" mode="aspectFit" v-if="item.cabinetType == 3"></image>
  74. <view class="info">
  75. <view class="message" v-for="(sub, j) in item.list" :key="j">
  76. <text>{{sub.description}},</text>
  77. <text class="num">{{sub.price}}</text>
  78. <text>元</text>
  79. </view>
  80. </view>
  81. </view>
  82. </block>
  83. <view class="btn" @click="closePriceDetail">知道了</view>
  84. </view>
  85. </uni-popup>
  86. <uni-popup ref="payPopup" type="center">
  87. <view class="pay-popup">
  88. <image class="delete-icon" :src="require('../../static/images/icon-delete.png')" @click="closePayDetail"></image>
  89. <view class="title">
  90. <text>请扫码支付,你的存物箱号为:{{order.caseSn}}</text>
  91. </view>
  92. <view class="code-box">
  93. <view class="item">
  94. <view class="qrcode">
  95. <!-- <canvas canvas-id="aliCode" /> -->
  96. <image :src="aliCodeImg"></image>
  97. <!-- <mosowe-canvas-image ref="aliCanvas" @canvasImage="aliCanvasImage" :lists="aliLists" height="40vw" width="40vw" /> -->
  98. </view>
  99. <view class="label">支付宝</view>
  100. </view>
  101. <view class="item">
  102. <view class="qrcode">
  103. <!-- <canvas canvas-id="weChatCode" /> -->
  104. <image :src="wxCodeImg"></image>
  105. <!-- <mosowe-canvas-image ref="wxCanvas" @canvasImage="wxCanvasImage" :lists="wxLists" height="40vw" width="40vw" /> -->
  106. </view>
  107. <view class="label">微信</view>
  108. </view>
  109. </view>
  110. </view>
  111. </uni-popup>
  112. </view>
  113. </template>
  114. <script>
  115. import navigationBarView from '../../components/navigationBarView.vue';
  116. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  117. import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
  118. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
  119. import uQRCode from '@/js_sdk/Sansnn-uQRCode/uqrcode.js';
  120. import mosoweCanvasImage from '@/components/mosowe-canvas-image/mosowe-canvas-image.vue'
  121. export default {
  122. components: {
  123. navigationBarView,
  124. uniPopup,
  125. uniPopupMessage,
  126. uniPopupDialog,
  127. mosoweCanvasImage
  128. },
  129. data() {
  130. return {
  131. selectedIndex: 0,
  132. rentOptionDtoList: [],
  133. timersIndex: 0,
  134. agreement: {},
  135. info: {},
  136. rentCabinetList: [],
  137. rentPopup: [],
  138. options: {},
  139. order: {},
  140. codeBody: {},
  141. timer: '',
  142. aliLists: [{
  143. type: 'qr',
  144. content: '',
  145. x: 0,
  146. y: 0,
  147. }],
  148. aliCodeImg: '',
  149. wxLists: [{
  150. type: 'qr',
  151. content: '',
  152. x: 0,
  153. y: 0,
  154. }],
  155. wxCodeImg: ''
  156. }
  157. },
  158. onLoad(options) {
  159. this.options = options
  160. this.getAgreement();
  161. this.getData();
  162. },
  163. onHide() {
  164. clearInterval(this.timer);
  165. const $this = this;
  166. $this.$nextTick(function() {
  167. $this.$refs.nav.clearTimer();
  168. })
  169. },
  170. beforeDestroy() {
  171. clearInterval(this.timer);
  172. },
  173. methods: {
  174. getData() {
  175. let sn = uni.getStorageSync('sn');
  176. this.$api.deviceInfo({
  177. deviceSn: sn
  178. }).then(res => {
  179. this.info = res.data;
  180. this.rentOptionDtoList = res.data.rentOptionDtoList;
  181. this.rentCabinetList = res.data.rentOptionDtoList.length ? res.data.rentOptionDtoList[this.timersIndex].rentCabinetList :
  182. [];
  183. let cabinetTypes = res.data.cabinetTypes.split(',')
  184. this.selectedIndex = Number(cabinetTypes[0]) - 1
  185. let lists = []
  186. // for (let i = 0; i < res.data.rentOptionDtoList.length; i++) {
  187. // let item = res.data.rentOptionDtoList[i];
  188. // for (let j = 0; j < item.rentCabinetList.length; j++) {
  189. // let rentCabinet = item.rentCabinetList[j];
  190. // rentCabinet.list = rentCabinet.list || []
  191. // let n = 0;
  192. // for (let k = 0; k < lists.length; k++) {
  193. // if (lists[k].cabinetType == rentCabinet.cabinetType) {
  194. // n++;
  195. // if (!lists[k].list) lists[k].list = []
  196. // lists[k].list.push({
  197. // ...item,
  198. // ...rentCabinet
  199. // })
  200. // }
  201. // }
  202. // if (n == 0) {
  203. // let list = [{
  204. // description: item.description,
  205. // price: rentCabinet.price
  206. // }]
  207. // rentCabinet.list = list
  208. // lists.push(rentCabinet)
  209. // }
  210. // }
  211. // }
  212. this.rentPopup = lists;
  213. })
  214. },
  215. changeSpec(e) {
  216. if (this.info.cabinetTypes.indexOf(String(e + 1)) == -1) {
  217. uni.showToast({
  218. icon: 'none',
  219. title: '该箱门不可用'
  220. })
  221. return;
  222. }
  223. this.selectedIndex = e
  224. },
  225. getAgreement() {
  226. this.$api.commonAboutus({
  227. type: 2
  228. }).then(res => {
  229. this.agreement = res;
  230. })
  231. },
  232. changeTimers(e) {
  233. this.timersIndex = e.detail.value
  234. },
  235. openAgreementPopup() {
  236. this.$nextTick(function() {
  237. this.$refs.agreementPopup.open();
  238. })
  239. },
  240. closeAgreementPopup() {
  241. this.$nextTick(function() {
  242. this.$refs.agreementPopup.close();
  243. })
  244. },
  245. aliCanvasImage(e) {
  246. this.aliCodeImg = e;
  247. },
  248. wxCanvasImage(e) {
  249. this.wxCodeImg = e;
  250. },
  251. orders() {
  252. const params = {
  253. cabinetType: this.rentCabinetList[this.selectedIndex].cabinetType,
  254. mobile: this.options.phone,
  255. optionId: this.rentOptionDtoList[this.timersIndex].id,
  256. deviceSn: uni.getStorageSync('sn')
  257. }
  258. this.$api.offorderCreateOffline(params).then(res => {
  259. console.log(res);
  260. this.order = res.order;
  261. this.codeBody.aliCode = res.aliCode;
  262. this.codeBody.wxCode = res.wxCode;
  263. this.aliCodeImg = res.aliCode;
  264. this.wxCodeImg = res.wxCode;
  265. const $this = this;
  266. let info = uni.getSystemInfoSync()
  267. // this.aliLists[0].content = res.aliCode;
  268. // this.aliLists[0].width = info.screenWidth * 0.4
  269. // this.aliLists[0].height = info.screenWidth * 0.4
  270. // this.wxLists[0].content = res.wxCode;
  271. // this.wxLists[0].width = info.screenWidth * 0.4
  272. // this.wxLists[0].height = info.screenWidth * 0.4
  273. this.$nextTick(function() {
  274. $this.$refs.nav.timer = 60;
  275. $this.$refs.nav.countdown()
  276. $this.$refs.payPopup.open();
  277. // setTimeout(function() {
  278. // $this.$refs.aliCanvas.createCanvas();
  279. // $this.$refs.wxCanvas.createCanvas();
  280. // }, 500)
  281. $this.timer = setInterval(function() {
  282. $this.getPayStatus();
  283. }, 3000)
  284. })
  285. })
  286. },
  287. getPayStatus() {
  288. this.$api.offorderGetStatus({
  289. orderSn: this.order.orderSn
  290. }).then(res => {
  291. if (res.status == 1) {
  292. clearInterval(this.timer);
  293. uni.redirectTo({
  294. url: '/pages/bagStorage/success?remind=' + this.order.remind
  295. })
  296. }
  297. })
  298. },
  299. showPriceDetail() {
  300. this.$nextTick(function() {
  301. this.$refs.priceDetailPopup.open();
  302. })
  303. },
  304. closePriceDetail() {
  305. this.$nextTick(function() {
  306. this.$refs.priceDetailPopup.close();
  307. })
  308. },
  309. closePayDetail() {
  310. clearInterval(this.timer)
  311. this.$nextTick(function() {
  312. this.$refs.payPopup.close();
  313. })
  314. },
  315. }
  316. }
  317. </script>
  318. <style lang="scss">
  319. .bagStorageOrders {
  320. min-height: 100vh;
  321. background-color: #F8F8F8;
  322. .label-box {
  323. padding: 7.7vw 5vw 2.9vw;
  324. color: #222222;
  325. font-size: 4.2vw;
  326. line-height: 4.2vw;
  327. }
  328. .selected-box {
  329. display: flex;
  330. align-items: center;
  331. flex-wrap: wrap;
  332. margin: 0 4.8vw;
  333. .item {
  334. position: relative;
  335. display: flex;
  336. align-items: center;
  337. flex-direction: column;
  338. width: 26.5vw;
  339. padding-bottom: 9vw;
  340. margin-right: 4.2vw;
  341. border: .4vw solid #EBEBEB;
  342. border-radius: .8vw;
  343. background-color: #FFFFFF;
  344. &:last-child {
  345. margin-right: 0;
  346. }
  347. &.active {
  348. border-color: #FFDB82;
  349. }
  350. .selected-icon {
  351. position: absolute;
  352. top: 0;
  353. right: 0;
  354. width: 5.4vw;
  355. height: 5.4vw;
  356. }
  357. .small-icon {
  358. margin-top: 11vw;
  359. width: 16.3vw;
  360. height: 6.9vw;
  361. }
  362. .label {
  363. margin-top: 6vw;
  364. font-weight: 500;
  365. color: #FFB706;
  366. font-size: 4.2vw;
  367. line-height: 4.2vw;
  368. }
  369. .message {
  370. margin-top: 2.7vw;
  371. color: #AAAAAA;
  372. font-size: 2.9vw;
  373. line-height: 2.9vw;
  374. }
  375. .middle-icon {
  376. margin-top: 11vw;
  377. width: 16.7vw;
  378. height: 6.7vw;
  379. }
  380. .big-icon {
  381. margin-top: 9.6vw;
  382. width: 16.7vw;
  383. height: 8.1vw;
  384. }
  385. }
  386. }
  387. .input-box {
  388. display: flex;
  389. align-items: center;
  390. justify-content: space-between;
  391. height: 13.3vw;
  392. border: .4vw solid #DEDEDE;
  393. background-color: #F4F4F4;
  394. padding: 0 3.5vw;
  395. margin: .3vw 4.8vw 0;
  396. color: #444444;
  397. font-size: 5vw;
  398. border-radius: .8vw;
  399. &.selected {
  400. border-color: #FBD87F;
  401. font-weight: 500;
  402. color: #FFB706;
  403. background-color: #FFFFFF;
  404. }
  405. .arrow {
  406. width: 2.3vw;
  407. height: 3.8vw;
  408. }
  409. }
  410. .agreement-box {
  411. margin: 8vw 5vw 0;
  412. font-size: 2.9vw;
  413. line-height: 2.9vw;
  414. .agreement {
  415. color: #008CFF;
  416. }
  417. }
  418. .footer-btn {
  419. display: flex;
  420. height: 16.7vw;
  421. margin: 4vw 5vw 3.8vw;
  422. .left {
  423. flex: 1;
  424. display: flex;
  425. justify-content: center;
  426. flex-direction: column;
  427. padding: 0 8.1vw;
  428. border-radius: 16.7vw 0 0 16.7vw;
  429. background-color: #0C0B09;
  430. .price {
  431. color: #FFFFFF;
  432. font-size: 6.3vw;
  433. line-height: 6.3vw;
  434. }
  435. .message {
  436. display: flex;
  437. align-items: center;
  438. margin-top: 2.3vw;
  439. color: #9E9D9D;
  440. font-size: 2.9vw;
  441. line-height: 2.9vw;
  442. .arrow {
  443. width: 1.3vw;
  444. height: 1.7vw;
  445. margin-left: .6vw;
  446. }
  447. }
  448. }
  449. .right {
  450. display: flex;
  451. align-items: center;
  452. justify-content: center;
  453. width: 35.4vw;
  454. border-radius: 0 16.7vw 16.7vw 0;
  455. background: linear-gradient(to right, #FEE704, #FDD001);
  456. font-size: 5vw;
  457. }
  458. }
  459. .agreement-popup {
  460. position: relative;
  461. width: 90.8vw;
  462. height: 70vh;
  463. background-color: #FFFFFF;
  464. border-radius: 1.7vw;
  465. overflow-y: scroll;
  466. .delete-icon {
  467. position: absolute;
  468. top: 4vw;
  469. right: 4vw;
  470. width: 3.3vw;
  471. height: 3.3vw;
  472. }
  473. .text-box {
  474. width: calc(100% - 11.6vw);
  475. height: 56.5vh;
  476. margin: 11.3vw 0 0;
  477. padding: 0 5.8vw;
  478. color: #888888;
  479. font-size: 3.2vw;
  480. }
  481. }
  482. .price-popup {
  483. position: relative;
  484. width: 90.8vw;
  485. height: 70vh;
  486. background-color: #FFFFFF;
  487. border-radius: 1.7vw;
  488. overflow-y: scroll;
  489. .delete-icon {
  490. position: absolute;
  491. top: 4vw;
  492. right: 4vw;
  493. width: 3.3vw;
  494. height: 3.3vw;
  495. }
  496. .title {
  497. margin-top: 14vw;
  498. text-align: center;
  499. font-weight: 500;
  500. font-size: 4.2vw;
  501. line-height: 4.2vw;
  502. .num {
  503. color: #FFB706;
  504. }
  505. }
  506. .label {
  507. margin: 7.3vw 5.8vw 5.6vw;
  508. font-size: 2.9vw;
  509. font-weight: 500;
  510. }
  511. .cell {
  512. display: flex;
  513. align-items: center;
  514. min-height: 18.5vw;
  515. margin: 0 5.8vw 1.9vw;
  516. border-radius: .8vw;
  517. background-color: #F8F8F8;
  518. .icon {
  519. width: 16.7vw;
  520. height: 6.7vw;
  521. margin: 0 11.5vw 0 6.5vw;
  522. }
  523. .info {
  524. flex: 1;
  525. .message {
  526. font-size: 2.1vw;
  527. line-height: 2.1vw;
  528. margin-bottom: 1.9vw;
  529. &:last-child {
  530. margin-bottom: 0;
  531. }
  532. .num {
  533. color: #FFB706;
  534. }
  535. }
  536. }
  537. }
  538. .btn {
  539. display: flex;
  540. align-items: center;
  541. justify-content: center;
  542. font-size: 5vw;
  543. line-height: 5vw;
  544. margin: 12.1vw 0 0;
  545. }
  546. }
  547. .pay-popup {
  548. position: relative;
  549. width: 90vw;
  550. min-height: 70vw;
  551. margin: 0 5.8vw 1.9vw;
  552. border-radius: .8vw;
  553. background-color: #F8F8F8;
  554. padding-top: 1rpx;
  555. .title {
  556. margin: 7vw 0;
  557. text-align: center;
  558. font-weight: 500;
  559. font-size: 4.2vw;
  560. line-height: 4.2vw;
  561. }
  562. .delete-icon {
  563. position: absolute;
  564. top: 4vw;
  565. right: 4vw;
  566. width: 3.3vw;
  567. height: 3.3vw;
  568. }
  569. .code-box {
  570. display: flex;
  571. align-items: center;
  572. justify-content: space-around;
  573. .item {
  574. display: flex;
  575. align-items: center;
  576. flex-direction: column;
  577. .qrcode {
  578. width: 40vw;
  579. height: 40vw;
  580. image {
  581. width: 40vw;
  582. height: 40vw;
  583. }
  584. }
  585. .label {
  586. margin-top: 2.9vw;
  587. font-size: 2.9vw;
  588. font-weight: 500;
  589. }
  590. }
  591. }
  592. }
  593. }
  594. </style>