detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <template>
  2. <view>
  3. <view class="demo" style="height: 180rpx;">
  4. <view class="detailMiddle">
  5. <text>精</text>
  6. <text>简</text>
  7. <text>高</text>
  8. <text>纯棉</text>
  9. <text>赠</text>
  10. <text>青春</text>
  11. <text>总计</text>
  12. </view>
  13. <view class="detailMiddleRed">
  14. <text v-for="(item,index) in numList" :key="index">{{ item }}</text>
  15. <text>{{ allNum }}</text>
  16. </view>
  17. </view>
  18. <!-- <view @click="getScan">
  19. 点击添加
  20. </view>
  21. <view @click="setC">
  22. 点击校验
  23. </view> -->
  24. <scroll-view :style="{height: scroll_height}" class="listBox" scroll-y="true">
  25. <view class="listBox_item" :class="(index + 1)%2 == 0 ? 'back' : ''" v-for="(item,index) in list"
  26. :key="index">
  27. <view style="display: flex;align-items: center;width:50%">
  28. <view class="left">
  29. {{ item.style }}
  30. </view>
  31. <view class="gray">
  32. {{ item.code_level==1?item.code_num:1 }}套{{item.code_level==1?`(1件)`:''}}
  33. </view>
  34. </view>
  35. <view class="right" @click="del(item.style,index)">
  36. 删除
  37. </view>
  38. </view>
  39. </scroll-view>
  40. <view class="fiexedEnd">
  41. <view class="fiexedEnd_title" @click="allDel">
  42. 全部清除
  43. </view>
  44. <view class="fiexedEnd_red" @click="getCode">
  45. 扫描
  46. </view>
  47. <view class="fiexedEnd_title" @click="sendSure">
  48. 确认发货
  49. </view>
  50. </view>
  51. <!-- <u-mask :show="fillOut">
  52. <view class="showTip">
  53. <image src="../../static/fangwei/show.png"></image>
  54. <view class="title">
  55. 温馨提示
  56. </view>
  57. <view class="remark">
  58. 是否确保这一件里的所有货没有调换过
  59. </view>
  60. <view class="btn">
  61. <view class="btn_left" @click="fillOut = false">
  62. 不确保
  63. </view>
  64. <view class="btn_right" @click="getCode">
  65. 确保
  66. </view>
  67. </view>
  68. </view>
  69. </u-mask> -->
  70. <u-mask :show="ifShow">
  71. <view class="showTip">
  72. <image src="../../static/fangwei/show.png"></image>
  73. <view class="title">
  74. 提示
  75. </view>
  76. <view class="remark">
  77. 添加成功!
  78. </view>
  79. <view class="btn">
  80. <view class="btn_left" @click="ifShow = false,clearTime()">
  81. 取消
  82. </view>
  83. <view class="btn_right" @click="getCode">
  84. 扫下一个({{ count }}s)
  85. </view>
  86. </view>
  87. </view>
  88. </u-mask>
  89. <u-modal v-model="show" :show-cancel-button="true" :content="content" @confirm="confirm"></u-modal>
  90. <u-toast ref="uToast" />
  91. </view>
  92. </template>
  93. <script>
  94. import {
  95. scanCode,
  96. UserSend,
  97. AllSendGood
  98. } from '../../apis/fangwei.js'
  99. import {
  100. location,
  101. } from '../../apis/user.js';
  102. var jweixin = require('jweixin-module');
  103. export default {
  104. data() {
  105. return {
  106. show: false,
  107. fillOut: false,
  108. delShow: false,
  109. ifShow: false,
  110. content: '',
  111. count: 3,
  112. list: [],
  113. id: '',
  114. scroll_height: 0,
  115. numList: [0, 0, 0, 0, 0, 0],
  116. info: {},
  117. code: '',
  118. allNum: 0,
  119. param: {},
  120. model: '', //手机型号
  121. }
  122. },
  123. // 获取可滑动区域的高度
  124. onReady: function(res) {
  125. var _this = this;
  126. uni.getSystemInfo({
  127. success: (resu) => {
  128. const query = uni.createSelectorQuery()
  129. query.select('.listBox').boundingClientRect()
  130. query.exec(function(res) {
  131. _this.scroll_height = resu.windowHeight - res[0].top + 'px';
  132. })
  133. },
  134. fail: (res) => {}
  135. })
  136. },
  137. onLoad: function(option) {
  138. this.id = option.id
  139. // 用于扫码发货
  140. uni.getSystemInfo({
  141. success: res => {
  142. this.model = res.model;
  143. }
  144. });
  145. if (this.model == 'iPhone') {
  146. uni.setStorageSync('url', window.location.href.split('#')[0])
  147. }
  148. // this.getInfo('21tJfNcVaKd04b1872275KDNN76Q0109') //一件
  149. // this.getInfo('21eDalw4pdbobc8725ea4C4QNKR_0109') //一套
  150. // this.getInfo('21As3wSFW4pV75d9e6bcF0A_N4N30109') //一套精装赠
  151. },
  152. methods: {
  153. setC() {
  154. this.count = 3
  155. this.ifShow = true
  156. this.setTime()
  157. let index = this.list.findIndex(item => item.code == '44444')
  158. if (index != -1) {
  159. console.log('存在')
  160. } else {
  161. console.log('不存在')
  162. }
  163. },
  164. // 测试扫描
  165. getScan() {
  166. var good = 4
  167. var style = this.getStyle(good)
  168. const data = {
  169. style: this.getStyle(good),
  170. styleId: 4,
  171. code: 44444
  172. }
  173. this.URLencode(data)
  174. console.log(data)
  175. this.list.unshift(data)
  176. console.log(this.list)
  177. this.addStyle(good)
  178. },
  179. setTime() {
  180. //设置定时器
  181. this.clearTimeSet = setInterval(() => {
  182. this.count--;
  183. if (this.count == 0) {
  184. this.ifShow = false
  185. this.clearTime()
  186. this.getCode()
  187. }
  188. }, 1000);
  189. },
  190. clearTime() {
  191. console.log('清除')
  192. //清除定时器
  193. clearInterval(this.clearTimeSet);
  194. },
  195. // 确认发货
  196. sendGood() {
  197. const data = {
  198. 1: [],
  199. 2: [],
  200. 3: [],
  201. 4: [],
  202. 5: [],
  203. 6: []
  204. }
  205. this.list.forEach((item, index, arr) => {
  206. data[item.styleId].push(item.code)
  207. })
  208. AllSendGood({
  209. id: this.id,
  210. code: data
  211. }).then(res => {
  212. if (res.code == 200) {
  213. uni.showToast({
  214. title: '发货成功',
  215. icon: 'none'
  216. })
  217. this.list = []
  218. this.numList = [0, 0, 0, 0]
  219. this.allNum = 0
  220. } else {
  221. uni.showModal({
  222. title: '错误提示',
  223. content: res.message || '发货失败',
  224. showCancel: false
  225. })
  226. }
  227. })
  228. },
  229. // 删除单个 弹窗
  230. del(item, i) {
  231. this.item = item
  232. this.i = i
  233. this.type = 1
  234. this.content = '确定要删除吗?'
  235. this.show = true
  236. },
  237. // 删除所有 弹窗
  238. allDel() {
  239. if (this.list.length == 0) {
  240. uni.showToast({
  241. title: '暂无货物',
  242. icon: 'none'
  243. })
  244. return false
  245. }
  246. this.content = '确定要全部清除吗?'
  247. this.type = 2
  248. this.show = true
  249. },
  250. // 发货调起确认框
  251. sendSure() {
  252. if (this.list.length == 0) {
  253. uni.showToast({
  254. title: '暂无货物',
  255. icon: 'none'
  256. })
  257. return false
  258. }
  259. this.type = 3
  260. this.show = true
  261. this.content = '确定要发货吗?'
  262. },
  263. confirm() {
  264. // 删除单个
  265. if (this.type == 1) {
  266. this.list.splice(this.i, 1)
  267. this.reduceStyle(this.item)
  268. uni.showToast({
  269. title: '删除成功',
  270. icon: 'none'
  271. })
  272. // 删除所有
  273. } else if (this.type == 2) {
  274. this.list = []
  275. this.numList = [0, 0, 0, 0, 0, 0]
  276. this.allNum = 0
  277. } else if (this.type == 3) {
  278. this.sendGood()
  279. }
  280. },
  281. // 款式
  282. getStyle(v) {
  283. if (v == 1) {
  284. return '精装版'
  285. } else if (v === 2) {
  286. return '简约版'
  287. } else if (v === 3) {
  288. return '高腰版'
  289. } else if (v === 4) {
  290. return '纯棉版'
  291. } else if (v === 5) {
  292. return '精装赠'
  293. } else if (v === 6) {
  294. return '青春版'
  295. }
  296. },
  297. // 增加款式数量
  298. addStyle(v) {
  299. if (v == 1) {
  300. this.numList[0] += 1
  301. } else if (v === 2) {
  302. this.numList[1] += 1
  303. } else if (v === 3) {
  304. this.numList[2] += 1
  305. } else if (v === 4) {
  306. this.numList[3] += 1
  307. } else if (v === 5) {
  308. this.numList[4] += 1
  309. } else if (v === 6) {
  310. this.numList[5] += 1
  311. }
  312. this.allNum += 1
  313. },
  314. // 减少款式数量
  315. reduceStyle(v) {
  316. if (v === '精装版') {
  317. this.numList[0] -= 1
  318. } else if (v === '简约版') {
  319. this.numList[1] -= 1
  320. } else if (v === '高腰版') {
  321. this.numList[2] -= 1
  322. } else if (v === '纯棉版') {
  323. this.numList[3] -= 1
  324. } else if (v === '精装赠') {
  325. this.numList[4] -= 1
  326. } else if (v === '青春版') {
  327. this.numList[5] -= 1
  328. }
  329. this.allNum -= 1
  330. },
  331. //获取信息
  332. getInfo(params) {
  333. UserSend({
  334. id: this.id,
  335. code: params
  336. }).then(res => {
  337. if (res.code == 200) {
  338. const data = {
  339. style: this.getStyle(res.data.good),
  340. styleId: res.data.good,
  341. code: params,
  342. code_level: res.data.code_level,
  343. code_num: res.data.code_num
  344. }
  345. this.list.unshift(data)
  346. this.addStyle(res.data.good)
  347. this.count = 3
  348. this.ifShow = true
  349. this.setTime()
  350. } else {
  351. uni.showModal({
  352. title: '错误提示',
  353. content: res.message || '获取信息失败',
  354. showCancel: false
  355. })
  356. }
  357. })
  358. },
  359. getCode() {
  360. this.ifShow = false
  361. this.clearTime()
  362. let link = window.location.href;
  363. let url = this.model == 'iPhone' ? uni.getStorageSync('url') : link
  364. location({
  365. url
  366. }).then(res => {
  367. if (res.code == 200) {
  368. let data = JSON.parse(res.data);
  369. // 判断是否支持扫码
  370. jweixin.config({
  371. debug: false, //开启debug模式.正式环境设置为false,测试环境设置为true
  372. appId: data.appId,
  373. timestamp: data.timestamp,
  374. nonceStr: data.nonceStr,
  375. signature: data.signature,
  376. jsApiList: ['scanQRCode'] //根据需要看需要哪些SDK的功能
  377. });
  378. // sdk加载完成后执行
  379. jweixin.ready(() => {
  380. jweixin.checkJsApi({
  381. jsApiList: ['scanQRCode'],
  382. success: res => {
  383. if (res.checkResult.scanQRCode == false) {
  384. alert('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!');
  385. return;
  386. }
  387. }
  388. });
  389. jweixin.error(res => {
  390. console.log(res.errMsg, '错误消息');
  391. });
  392. //扫码
  393. jweixin.scanQRCode({
  394. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  395. scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  396. success: res => {
  397. var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
  398. var site = result.lastIndexOf('\/')
  399. var params = result.substring(site + 1, result.length)
  400. this.code = window.encodeURIComponent(params)
  401. let index = this.list.findIndex(item => item.code == this
  402. .code)
  403. if (index != -1) {
  404. uni.showModal({
  405. title: '错误提示',
  406. content: '此码已添加,请勿重复扫描',
  407. showCancel: false
  408. })
  409. } else {
  410. this.getInfo(this.code)
  411. }
  412. },
  413. fail: () => {
  414. location.href = location.protocol + '//' + location.host +
  415. "/pages/scanQR/detail";
  416. },
  417. });
  418. });
  419. } else {
  420. uni.showModal({
  421. title: '错误提示',
  422. content: res.message || '获取信息失败',
  423. showCancel: false
  424. })
  425. }
  426. });
  427. }
  428. // getCode() {
  429. // this.ifShow = false
  430. // this.clearTime()
  431. // // this.fillOut = false
  432. // const script = document.createElement('script');
  433. // script.type = 'text/javascript';
  434. // script.src = 'http://res.wx.qq.com/open/js/jweixin-1.4.0.js';
  435. // document.getElementsByTagName('head')[0].appendChild(script);
  436. // script.onload = () => {
  437. // scanCode().then(res => {
  438. // if (res.code == 200) {
  439. // wx.config({
  440. // debug: false, // 开启调试模式
  441. // appId: res.data.appId, // 必填,公众号的唯一标识
  442. // timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  443. // nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
  444. // signature: res.data.signature, // 必填,签名,见附录1
  445. // jsApiList: res.data.jsApiList // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  446. // })
  447. // wx.ready(() => {
  448. // wx.scanQRCode({
  449. // needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  450. // scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  451. // success: res => {
  452. // var result = res
  453. // .resultStr; // 当needResult 为 1 时,扫码返回的结果
  454. // var site = result.lastIndexOf('\/')
  455. // var params = result.substring(site + 1, result
  456. // .length)
  457. // this.code = window.encodeURIComponent(params)
  458. // let index = this.list.findIndex(item => item
  459. // .code == this.code)
  460. // if (index != -1) {
  461. // uni.showModal({
  462. // title: '错误提示',
  463. // content: '此码已添加,请勿重复扫描',
  464. // showCancel: false
  465. // })
  466. // } else {
  467. // this.getInfo(this.code)
  468. // }
  469. // }
  470. // })
  471. // })
  472. // } else {
  473. // uni.showModal({
  474. // title: '错误提示',
  475. // content: res.message || '获取信息失败',
  476. // showCancel: false
  477. // })
  478. // }
  479. // });
  480. // };
  481. // }
  482. }
  483. }
  484. </script>
  485. <style>
  486. page {
  487. background-color: #fff;
  488. }
  489. </style>
  490. <style lang="scss" scoped>
  491. .showTip {
  492. position: fixed;
  493. left: 0;
  494. right: 0;
  495. top: 30%;
  496. margin: auto;
  497. width: 648rpx;
  498. height: 368rpx;
  499. background: #FFFFFF;
  500. border-radius: 24rpx;
  501. z-index: 10000;
  502. display: flex;
  503. justify-content: space-between;
  504. align-items: center;
  505. flex-direction: column;
  506. padding-bottom: 34rpx;
  507. image {
  508. width: 180rpx;
  509. height: 136rpx;
  510. margin-top: -68rpx;
  511. }
  512. .title {
  513. font-size: 38rpx;
  514. font-weight: bold;
  515. color: #333333;
  516. }
  517. .remark {
  518. font-size: 34rpx;
  519. font-weight: 400;
  520. color: #333333;
  521. }
  522. .btn {
  523. display: flex;
  524. view {
  525. width: 242rpx;
  526. height: 88rpx;
  527. border-radius: 44rpx;
  528. text-align: center;
  529. line-height: 88rpx;
  530. font-size: 32rpx;
  531. font-weight: bold;
  532. }
  533. &_left {
  534. background: #F5F5F5;
  535. color: #333333;
  536. }
  537. &_right {
  538. margin-left: 24rpx;
  539. background: linear-gradient(93deg, #F30000 0%, #FE4815 100%);
  540. color: #fff;
  541. }
  542. }
  543. }
  544. .detailTop {
  545. padding: 24rpx 0 0 24rpx;
  546. display: flex;
  547. align-items: center;
  548. &_left {
  549. width: 136rpx;
  550. font-size: 34rpx;
  551. font-weight: bold;
  552. color: #333333;
  553. }
  554. &_right {
  555. width: 566rpx;
  556. height: 104rpx;
  557. background: #F8F8F8;
  558. border-radius: 8rpx;
  559. line-height: 104rpx;
  560. padding-left: 28rpx;
  561. color: #333;
  562. font-size: 32rpx;
  563. }
  564. }
  565. .detailMiddle {
  566. display: flex;
  567. align-items: center;
  568. justify-content: space-between;
  569. padding: 0 10rpx;
  570. text {
  571. // display: flex;
  572. display: inline-block;
  573. width: 16%;
  574. text-align: center;
  575. line-height: 90rpx;
  576. font-size: 32rpx;
  577. font-weight: bold;
  578. }
  579. }
  580. .detailMiddleRed {
  581. display: flex;
  582. align-items: center;
  583. justify-content: space-between;
  584. background-color: #FFF4F3;
  585. // padding: 0 10rpx;
  586. text {
  587. display: flex;
  588. display: inline-block;
  589. width: 16%;
  590. text-align: center;
  591. line-height: 90rpx;
  592. font-size: 32rpx;
  593. font-weight: bold;
  594. color: #FB231F;
  595. }
  596. }
  597. .listBox {
  598. padding-bottom: 104rpx;
  599. // height: 1500rpx;
  600. .back {
  601. background-color: #F8F8F8;
  602. }
  603. &_item {
  604. display: flex;
  605. justify-content: space-between;
  606. align-items: center;
  607. padding: 0 24rpx;
  608. height: 104rpx;
  609. .left {
  610. font-weight: bold;
  611. font-size: 32rpx;
  612. }
  613. .gray {
  614. margin-left: 70rpx;
  615. // width: 80rpx;
  616. text-align: center;
  617. font-size: 32rpx;
  618. font-weight: bold;
  619. color: #999999;
  620. }
  621. .right {
  622. width: 132rpx;
  623. height: 64rpx;
  624. background: linear-gradient(141deg, #F30000 0%, #FE4815 100%);
  625. border-radius: 34rpx;
  626. line-height: 64rpx;
  627. text-align: center;
  628. color: #fff;
  629. font-size: 28rpx;
  630. }
  631. }
  632. }
  633. .fiexedEnd {
  634. position: fixed;
  635. left: 0;
  636. bottom: 0;
  637. width: 100%;
  638. height: 104rpx;
  639. background: #FFFFFF;
  640. box-shadow: 0rpx -4rpx 24rpx rgba(0, 0, 0, 0.1);
  641. padding: 0 72rpx 18rpx 72rpx;
  642. font-size: 32rpx;
  643. font-weight: bold;
  644. display: flex;
  645. justify-content: space-between;
  646. align-items: flex-end;
  647. &_red {
  648. width: 172rpx;
  649. height: 172rpx;
  650. background: linear-gradient(150deg, #FFAA01 0%, #FE0000 100%);
  651. box-shadow: 0px 6rpx 20rpx rgba(254, 34, 0, 0.43);
  652. border-radius: 50%;
  653. font-size: 40rpx;
  654. color: #fff;
  655. line-height: 172rpx;
  656. text-align: center;
  657. }
  658. &_title {
  659. margin-bottom: 12rpx;
  660. }
  661. }
  662. </style>