orderDel.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <view class="container">
  3. <u-navbar leftIconColor="#fff" titleStyle="color:#fff;fontSize:36rpx;" :autoBack="true" bgColor="#2C6FF3"
  4. :placeholder="true" title="手动扣款"></u-navbar>
  5. <view class="video-container">
  6. <video :src="videoUrl" style="width: 100%;"></video>
  7. <view class="flex align-center justify-between" style="padding:0 24rpx;">
  8. <view class="video-tab">
  9. <u-subsection :list="videoType" activeColor="#2C6FF3" :current="videoCurrent"
  10. @change="sectionChange">
  11. </u-subsection>
  12. </view>
  13. <view class="flex">
  14. <view>
  15. <xbutton size="mini" padding="0 20rpx" @tap='addCom(deviceId)'>添加商品</xbutton>
  16. </view>
  17. <view style="margin-left: 24rpx;">
  18. <xbutton size="mini" width='180rpx' @tap='submit'>提交补扣申请</xbutton>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="goods-select" v-if="goodsList.length>0">
  24. <u-scroll-list :indicator="indicator" indicatorColor="#fff0f0" indicatorActiveColor="#f56c6c">
  25. <view class="flex justify-around">
  26. <view class="goods-item" v-for="(item,index) in goodsList" :key="index">
  27. <view class="flex flex-direction align-center justify-center image-dele-container goodContainer"
  28. @tap="clean(index,item)">
  29. <!-- <view class="flex align-center justify-center numberContainer">
  30. {{value}}
  31. </view> -->
  32. <view class="image">
  33. <u--image radius="4" width="100rpx" height="100rpx" :src="item.goodsImg" mode="aspectFit"
  34. :lazy-lord="true"></u--image>
  35. </view>
  36. <view class="goods-select-name">{{item.name}}</view>
  37. </view>
  38. <view class="flex align-center justify-center" style="margin-top: 8rpx;">
  39. <view class="flex align-center justify-center">
  40. <view class="minus" @tap="reduce(item,index)">
  41. <u-icon name="minus" size="12"></u-icon>
  42. </view>
  43. <text style="width: 50rpx;text-align: center;" class="input">{{item.number}}</text>
  44. <view class="plus" @tap="add(item)">
  45. <u-icon name="plus" color="#FFFFFF" size="12"></u-icon>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </u-scroll-list>
  52. </view>
  53. <view class="goods-select-empty" v-else>
  54. 添加需要补扣的商品~
  55. </view>
  56. <view class="classify-wrap">
  57. <Classify :status="status" :commList="commList"
  58. @comClick='detail' :height="fullHeight" :leftShow="false" />
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import {
  64. ownerGoodsList,
  65. list
  66. } from "@/api/commodity/goods.js"
  67. import {
  68. apply
  69. } from "@/api/order/riskorder.js"
  70. import {
  71. categoryList
  72. } from "@/api/device/device.js"
  73. import Classify from "@/components/classify/index.vue"
  74. export default {
  75. components: {
  76. Classify
  77. },
  78. data() {
  79. return {
  80. scrollintoview: '',
  81. fullHeight: '0',
  82. tabList: [], //商品类目
  83. commList: [], //商品列表
  84. goodsList: [], //商品id列表
  85. status: 'nomore', //加载更多
  86. riskId: '',
  87. deviceId: '',
  88. video: {
  89. url1: '',
  90. url2: ''
  91. },
  92. videoUrl: null,
  93. videoType: ['主视频', '副视频'],
  94. videoCurrent: 0,
  95. statGoodsList: [], //平台识别补扣商品
  96. }
  97. },
  98. onLoad(e) {
  99. let _this = this;
  100. const query = uni.createSelectorQuery().in(this);
  101. query.select(".classify-wrap").boundingClientRect((data) => {
  102. uni.getSystemInfo({
  103. success(res) {
  104. // 针对iPhone X等机型底部安全距离做适配
  105. const model = res.model;
  106. const modelInclude = [
  107. "iPhone X",
  108. 'iPhone XR',
  109. "iPhone XS",
  110. "iPhone XS MAX",
  111. "iPhone 12/13 mini",
  112. "iPhone 12/13 (Pro)",
  113. "iPhone 12/13 Pro Max",
  114. "iPhone 14 Pro Max"
  115. ];
  116. let safeDistance = modelInclude.includes(model)
  117. //动态设置商品区域高度
  118. if (safeDistance) {
  119. _this.fullHeight = res.windowHeight - data.top - 34 + 'px';
  120. } else {
  121. _this.fullHeight = res.windowHeight - data.top + 'px';
  122. }
  123. },
  124. });
  125. }).exec();
  126. // uni.getSystemInfo({
  127. // success(res) {
  128. // _this.fullHeight = 2 * (res.windowHeight - res.statusBarHeight - 44 - 143) + 'rpx';
  129. // },
  130. // });
  131. this.riskId = e.id
  132. this.deviceId = e.deviceId
  133. this.initOrder()
  134. },
  135. onShow() {
  136. this.getCommList()
  137. },
  138. methods: {
  139. //初始化页面信息
  140. initOrder() {
  141. let orderDetail = JSON.parse(uni.getStorageSync('riskOrder'));
  142. if (orderDetail.video) {
  143. this.video = {
  144. url1: orderDetail.video.split(',')[0],
  145. url2: orderDetail.video.split(',')[1]
  146. }
  147. this.videoUrl = this.video.url1
  148. } else {
  149. this.video = {
  150. url1: '',
  151. url2: ''
  152. }
  153. }
  154. let tempGoodsList = orderDetail.orderGoods.map(i => {
  155. return {
  156. goodsImg: i.goodsImgUrl,
  157. spid: i.goodsId,
  158. name: i.goodsName,
  159. price: Number(i.totalMoney) / 100,
  160. number: Number(i.totalNumber),
  161. initNum: Number(i.totalNumber)
  162. }
  163. })
  164. this.statGoodsList = JSON.parse(JSON.stringify(tempGoodsList))
  165. this.goodsList = JSON.parse(JSON.stringify(tempGoodsList))
  166. },
  167. sectionChange(e) {
  168. this.videoCurrent = e;
  169. if (e == 0) {
  170. this.videoUrl = this.video.url1
  171. } else {
  172. this.videoUrl = this.video.url2
  173. }
  174. },
  175. //根据类目获取商品列表
  176. getCommList() {
  177. list({
  178. deviceId: this.deviceId,
  179. }).then(res => {
  180. let data = res.data;
  181. let newData = data.map(i => {
  182. i.price = (Number(i.price) / 100).toFixed(2)
  183. return i
  184. })
  185. this.commList = newData
  186. })
  187. },
  188. statGoodsTips() {
  189. this.$modal.msg('该商品为平台算法识别异常商品,为防止您的无辜损失,无法再删减!')
  190. },
  191. clean(e, item) { //点击移除商品
  192. //校验是否算法识别商品
  193. if (this.isStatGoods(item)) {
  194. this.statGoodsTips()
  195. return
  196. }
  197. this.goodsList.splice(e, 1)
  198. },
  199. // 校验是否算法识别商品
  200. isStatGoods(e) {
  201. console.log(e)
  202. console.log(this.statGoodsList)
  203. for (let i = 0; i < this.statGoodsList.length; i++) {
  204. let item = this.statGoodsList[i];
  205. if (item.spid == e.spid) {
  206. return true
  207. }
  208. }
  209. return false
  210. },
  211. //校验是否减少了算法识别商品
  212. isDelStatGoods(e) {
  213. for (let i = 0; i < this.statGoodsList.length; i++) {
  214. let item = this.statGoodsList[i];
  215. if (item.spid == e.spid && item.number == e.number) {
  216. return true
  217. }
  218. }
  219. return false
  220. },
  221. detail(e) {
  222. this.goodsList.forEach(item => {
  223. if (e.goodsId == item.spid) {
  224. this.add(item)
  225. }
  226. })
  227. for (var i = 0; i < this.goodsList.length; i++) {
  228. if (this.goodsList[i].spid == e.goodsId) {
  229. return;
  230. }
  231. }
  232. this.goodsList.push({
  233. goodsImg: e.cover,
  234. spid: e.goodsId,
  235. name: e.name,
  236. price: e.price,
  237. number: 1,
  238. initNum: 0
  239. })
  240. },
  241. //新增
  242. add(e) {
  243. e.number++
  244. },
  245. //减少
  246. reduce(e, index) {
  247. if (this.isDelStatGoods(e)) { //校验是否减少了算法识别商品
  248. this.statGoodsTips()
  249. return
  250. }
  251. e.number--
  252. if (e.number == 0) {
  253. this.goodsList.splice(index, 1)
  254. }
  255. },
  256. reset() {
  257. this.status == 'loadmore'
  258. this.page = 1;
  259. this.size = 10;
  260. this.commList = [];
  261. },
  262. // 添加商品至机器
  263. addCom(deviceId){
  264. this.$tab.navigateTo('/pages/equipment/addCom?id='+deviceId)
  265. },
  266. //提交补扣申请
  267. submit() {
  268. if (!this.goodsList.length) {
  269. uni.$u.toast('请选择商品')
  270. return;
  271. }
  272. var goodsId = []
  273. this.goodsList.forEach(item => {
  274. if (item.number - item.initNum > 0) { //除去算法识别商品
  275. goodsId.push({
  276. goodsId: item.spid,
  277. goodsName: item.name,
  278. price: (Number(item.price)) * 100,
  279. totalNumber: item.number - item.initNum
  280. })
  281. }
  282. })
  283. apply({
  284. "cutGoods": goodsId,
  285. "riskId": this.riskId
  286. }).then(res => {
  287. this.$modal.msg('提交申请成功~')
  288. setTimeout(() => {
  289. this.$tab.navigateBack()
  290. }, 800)
  291. })
  292. }
  293. },
  294. onUnload() {
  295. uni.setStorage('riskOrder', '')
  296. },
  297. }
  298. </script>
  299. <style lang="scss" scoped>
  300. .container {
  301. .martop {
  302. margin-top: 20rpx;
  303. }
  304. .margin {
  305. margin: 10rpx 20rpx;
  306. }
  307. .margintop {
  308. margin-top: 10rpx;
  309. }
  310. .video-container {
  311. .video-tab {
  312. width: 300rpx;
  313. }
  314. }
  315. .box {
  316. padding: 20rpx 24rpx;
  317. }
  318. .goods-item+.goods-item {
  319. margin-left: 12rpx;
  320. }
  321. .image-dele-container {
  322. position: relative;
  323. width: 140rpx;
  324. height: 140rpx;
  325. background-color: #f6f6f6;
  326. border-radius: 15rpx;
  327. padding: 12rpx;
  328. view {
  329. text-overflow: ellipsis;
  330. overflow: hidden;
  331. white-space: nowrap;
  332. width: 100rpx;
  333. }
  334. .image {
  335. width: 100rpx;
  336. height: 100rpx;
  337. }
  338. .goods-select-name {
  339. font-size: 24rpx;
  340. }
  341. }
  342. .goods-select {
  343. margin: 0 24rpx;
  344. height: 218rpx;
  345. padding-top: 10rpx;
  346. }
  347. .goods-select-empty {
  348. height: 218rpx;
  349. text-align: center;
  350. line-height: 218rpx;
  351. }
  352. .goodContainer {
  353. position: relative;
  354. .numberContainer {
  355. width: 35rpx;
  356. height: 35rpx;
  357. border-radius: 100%;
  358. color: #fff;
  359. background-color: red;
  360. position: absolute;
  361. right: -5rpx;
  362. top: -5rpx;
  363. }
  364. }
  365. .minus {
  366. width: 22px;
  367. height: 22px;
  368. border-width: 1px;
  369. border-color: #E6E6E6;
  370. border-style: solid;
  371. border-top-left-radius: 100px;
  372. border-top-right-radius: 100px;
  373. border-bottom-left-radius: 100px;
  374. border-bottom-right-radius: 100px;
  375. @include flex;
  376. justify-content: center;
  377. align-items: center;
  378. }
  379. .plus {
  380. width: 18px;
  381. height: 18px;
  382. background-color: #FF0000;
  383. border-radius: 50%;
  384. /* #ifndef APP-NVUE */
  385. display: flex;
  386. /* #endif */
  387. justify-content: center;
  388. align-items: center;
  389. }
  390. }
  391. </style>