newDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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;">
  28. <view class="gray">
  29. {{ list.length - index }}
  30. </view>
  31. <view class="left">
  32. {{ item.style }}
  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="fillOut = true">
  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. export default {
  100. data() {
  101. return {
  102. show: false,
  103. fillOut: false,
  104. delShow: false,
  105. ifShow: false,
  106. content: '',
  107. count: 3,
  108. list: [],
  109. id: '',
  110. scroll_height: 0,
  111. numList: [0, 0, 0, 0, 0, 0],
  112. info: {},
  113. code: '',
  114. allNum: 0,
  115. param: {}
  116. }
  117. },
  118. // 获取可滑动区域的高度
  119. onReady: function(res) {
  120. var _this = this;
  121. uni.getSystemInfo({
  122. success: (resu) => {
  123. const query = uni.createSelectorQuery()
  124. query.select('.listBox').boundingClientRect()
  125. query.exec(function(res) {
  126. _this.scroll_height = resu.windowHeight - res[0].top + 'px';
  127. })
  128. },
  129. fail: (res) => {}
  130. })
  131. },
  132. onLoad: function(option) {
  133. this.id = option.id
  134. },
  135. methods: {
  136. setC() {
  137. this.count = 3
  138. this.ifShow = true
  139. this.setTime()
  140. let index = this.list.findIndex(item => item.code == '44444')
  141. if (index != -1) {
  142. console.log('存在')
  143. } else {
  144. console.log('不存在')
  145. }
  146. },
  147. // 测试扫描
  148. getScan() {
  149. var good = 6
  150. var style = this.getStyle(good)
  151. const data = {
  152. style: this.getStyle(good),
  153. styleId: 6,
  154. code: 6666
  155. }
  156. this.list.unshift(data)
  157. console.log(this.list)
  158. this.addStyle(good)
  159. },
  160. setTime() {
  161. //设置定时器
  162. this.clearTimeSet = setInterval(() => {
  163. this.count--;
  164. if (this.count == 0) {
  165. this.ifShow = false
  166. this.clearTime()
  167. this.getCode()
  168. }
  169. }, 1000);
  170. },
  171. clearTime() {
  172. //清除定时器
  173. clearInterval(this.clearTimeSet);
  174. },
  175. // 确认发货
  176. sendGood() {
  177. const data = {
  178. 1: [],
  179. 2: [],
  180. 3: [],
  181. 4: []
  182. }
  183. this.list.forEach((item, index, arr) => {
  184. data[item.styleId].push(item.code)
  185. })
  186. AllSendGood({
  187. id: this.id,
  188. code: data
  189. }).then(res => {
  190. if (res.code == 200) {
  191. uni.showToast({
  192. title: '发货成功',
  193. icon: 'none'
  194. })
  195. this.list = []
  196. this.numList = [0, 0, 0, 0]
  197. this.allNum = 0
  198. } else {
  199. uni.showModal({
  200. title: '错误提示',
  201. content: res.message || '发货失败',
  202. showCancel: false
  203. })
  204. }
  205. })
  206. },
  207. // 删除单个 弹窗
  208. del(item, i) {
  209. this.item = item
  210. this.i = i
  211. this.type = 1
  212. this.content = '确定要删除吗?'
  213. this.show = true
  214. },
  215. // 删除所有 弹窗
  216. allDel() {
  217. if (this.list.length == 0) {
  218. uni.showToast({
  219. title: '暂无货物',
  220. icon: 'none'
  221. })
  222. return false
  223. }
  224. this.content = '确定要全部清除吗?'
  225. this.type = 2
  226. this.show = true
  227. },
  228. // 发货调起确认框
  229. sendSure() {
  230. if (this.list.length == 0) {
  231. uni.showToast({
  232. title: '暂无货物',
  233. icon: 'none'
  234. })
  235. return false
  236. }
  237. this.type = 3
  238. this.show = true
  239. this.content = '确定要发货吗?'
  240. },
  241. confirm() {
  242. // 删除单个
  243. if (this.type == 1) {
  244. this.list.splice(this.i, 1)
  245. this.reduceStyle(this.item)
  246. uni.showToast({
  247. title: '删除成功',
  248. icon: 'none'
  249. })
  250. // 删除所有
  251. } else if (this.type == 2) {
  252. this.list = []
  253. this.numList = [0, 0, 0, 0]
  254. this.allNum = 0
  255. } else if (this.type == 3) {
  256. this.sendGood()
  257. }
  258. },
  259. // 款式
  260. getStyle(v) {
  261. if (v == 1) {
  262. return '精装版'
  263. } else if (v == 2) {
  264. return '简约版'
  265. } else if (v == 3) {
  266. return '高腰版'
  267. } else if (v == 4) {
  268. return '纯棉版'
  269. } else if (v == 5) {
  270. return '赠品'
  271. } else if (v == 6) {
  272. return '青春版'
  273. }
  274. },
  275. // 增加款式数量
  276. addStyle(v) {
  277. if (v == 1) {
  278. this.numList[0] += 1
  279. } else if (v === 2) {
  280. this.numList[1] += 1
  281. } else if (v === 3) {
  282. this.numList[2] += 1
  283. } else if (v === 4) {
  284. this.numList[3] += 1
  285. } else if (v === 5) {
  286. this.numList[4] += 1
  287. } else if (v === 6) {
  288. this.numList[5] += 1
  289. }
  290. this.allNum += 1
  291. },
  292. // 减少款式数量
  293. reduceStyle(v) {
  294. if (v === '精装版') {
  295. this.numList[0] -= 1
  296. } else if (v === '简约版') {
  297. this.numList[1] -= 1
  298. } else if (v === '高腰版') {
  299. this.numList[2] -= 1
  300. } else if (v === '纯棉版') {
  301. this.numList[3] -= 1
  302. } else if (v === '赠品') {
  303. this.numList[4] -= 1
  304. } else if (v === '青春版') {
  305. this.numList[5] -= 1
  306. }
  307. this.allNum -= 1
  308. },
  309. //获取信息
  310. getInfo(params) {
  311. UserSend({
  312. id: this.id,
  313. code: params,
  314. }).then(res => {
  315. if (res.code == 200) {
  316. const data = {
  317. style: this.getStyle(res.data.good),
  318. styleId: res.data.good,
  319. code: params
  320. }
  321. this.list.unshift(data)
  322. this.addStyle(res.data.good)
  323. this.count = 3
  324. this.ifShow = true
  325. this.setTime()
  326. } else {
  327. uni.showModal({
  328. title: '错误提示',
  329. content: res.message || '获取信息失败',
  330. showCancel: false
  331. })
  332. }
  333. })
  334. },
  335. getCode() {
  336. this.ifShow = false
  337. this.clearTime()
  338. this.fillOut = false
  339. const script = document.createElement('script');
  340. script.type = 'text/javascript';
  341. script.src = 'http://res.wx.qq.com/open/js/jweixin-1.4.0.js';
  342. document.getElementsByTagName('head')[0].appendChild(script);
  343. script.onload = () => {
  344. scanCode().then(res => {
  345. if (res.code == 200) {
  346. wx.config({
  347. debug: false, // 开启调试模式
  348. appId: res.data.appId, // 必填,公众号的唯一标识
  349. timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  350. nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
  351. signature: res.data.signature, // 必填,签名,见附录1
  352. jsApiList: res.data.jsApiList // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  353. })
  354. wx.ready(() => {
  355. wx.scanQRCode({
  356. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  357. scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  358. success: res => {
  359. var result = res
  360. .resultStr; // 当needResult 为 1 时,扫码返回的结果
  361. var site = result.lastIndexOf('\/')
  362. var params = result.substring(site + 1, result
  363. .length)
  364. this.code = window.encodeURIComponent(params)
  365. let index = this.list.findIndex(item => item
  366. .code == this.code)
  367. if (index != -1) {
  368. uni.showModal({
  369. title: '错误提示',
  370. content: '此码已添加,请勿重复扫描',
  371. showCancel: false
  372. })
  373. } else {
  374. this.getInfo(this.code)
  375. }
  376. }
  377. })
  378. })
  379. } else {
  380. uni.showModal({
  381. title: '错误提示',
  382. content: res.message || '获取信息失败',
  383. showCancel: false
  384. })
  385. }
  386. });
  387. };
  388. }
  389. }
  390. }
  391. </script>
  392. <style>
  393. page {
  394. background-color: #fff;
  395. }
  396. </style>
  397. <style lang="scss" scoped>
  398. .showTip {
  399. position: fixed;
  400. left: 0;
  401. right: 0;
  402. top: 30%;
  403. margin: auto;
  404. width: 648rpx;
  405. height: 368rpx;
  406. background: #FFFFFF;
  407. border-radius: 24rpx;
  408. z-index: 10000;
  409. display: flex;
  410. justify-content: space-between;
  411. align-items: center;
  412. flex-direction: column;
  413. padding-bottom: 34rpx;
  414. image {
  415. width: 180rpx;
  416. height: 136rpx;
  417. margin-top: -68rpx;
  418. }
  419. .title {
  420. font-size: 38rpx;
  421. font-weight: bold;
  422. color: #333333;
  423. }
  424. .remark {
  425. font-size: 34rpx;
  426. font-weight: 400;
  427. color: #333333;
  428. }
  429. .btn {
  430. display: flex;
  431. view {
  432. width: 242rpx;
  433. height: 88rpx;
  434. border-radius: 44rpx;
  435. text-align: center;
  436. line-height: 88rpx;
  437. font-size: 32rpx;
  438. font-weight: bold;
  439. }
  440. &_left {
  441. background: #F5F5F5;
  442. color: #333333;
  443. }
  444. &_right {
  445. margin-left: 24rpx;
  446. background: linear-gradient(93deg, #F30000 0%, #FE4815 100%);
  447. color: #fff;
  448. }
  449. }
  450. }
  451. .detailTop {
  452. padding: 24rpx 0 0 24rpx;
  453. display: flex;
  454. align-items: center;
  455. &_left {
  456. width: 136rpx;
  457. font-size: 34rpx;
  458. font-weight: bold;
  459. color: #333333;
  460. }
  461. &_right {
  462. width: 566rpx;
  463. height: 104rpx;
  464. background: #F8F8F8;
  465. border-radius: 8rpx;
  466. line-height: 104rpx;
  467. padding-left: 28rpx;
  468. color: #333;
  469. font-size: 32rpx;
  470. }
  471. }
  472. .detailMiddle {
  473. display: flex;
  474. align-items: center;
  475. justify-content: space-between;
  476. padding: 0 10rpx;
  477. text {
  478. display: inline-block;
  479. width: 14%;
  480. text-align: center;
  481. line-height: 90rpx;
  482. font-size: 32rpx;
  483. font-weight: bold;
  484. }
  485. }
  486. .detailMiddleRed {
  487. display: flex;
  488. align-items: center;
  489. justify-content: space-between;
  490. background-color: #FFF4F3;
  491. padding: 0 10rpx;
  492. text {
  493. display: inline-block;
  494. width: 14%;
  495. text-align: center;
  496. line-height: 90rpx;
  497. font-size: 32rpx;
  498. font-weight: bold;
  499. color: #FB231F;
  500. }
  501. }
  502. .listBox {
  503. padding-bottom: 104rpx;
  504. // height: 1500rpx;
  505. .back {
  506. background-color: #F8F8F8;
  507. }
  508. &_item {
  509. display: flex;
  510. justify-content: space-between;
  511. align-items: center;
  512. padding: 0 24rpx;
  513. height: 104rpx;
  514. .left {
  515. margin-left: 70rpx;
  516. font-weight: bold;
  517. font-size: 32rpx;
  518. }
  519. .gray {
  520. width: 80rpx;
  521. text-align: center;
  522. font-size: 32rpx;
  523. font-weight: bold;
  524. color: #999999;
  525. }
  526. .right {
  527. width: 132rpx;
  528. height: 64rpx;
  529. background: linear-gradient(141deg, #F30000 0%, #FE4815 100%);
  530. border-radius: 34rpx;
  531. line-height: 64rpx;
  532. text-align: center;
  533. color: #fff;
  534. font-size: 28rpx;
  535. }
  536. }
  537. }
  538. .fiexedEnd {
  539. position: fixed;
  540. left: 0;
  541. bottom: 0;
  542. width: 100%;
  543. height: 104rpx;
  544. background: #FFFFFF;
  545. box-shadow: 0rpx -4rpx 24rpx rgba(0, 0, 0, 0.1);
  546. padding: 0 72rpx 18rpx 72rpx;
  547. font-size: 32rpx;
  548. font-weight: bold;
  549. display: flex;
  550. justify-content: space-between;
  551. align-items: flex-end;
  552. &_red {
  553. width: 172rpx;
  554. height: 172rpx;
  555. background: linear-gradient(150deg, #FFAA01 0%, #FE0000 100%);
  556. box-shadow: 0px 6rpx 20rpx rgba(254, 34, 0, 0.43);
  557. border-radius: 50%;
  558. font-size: 40rpx;
  559. color: #fff;
  560. line-height: 172rpx;
  561. text-align: center;
  562. }
  563. &_title {
  564. margin-bottom: 12rpx;
  565. }
  566. }
  567. </style>