choosePart.vue 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  1. <template>
  2. <view class="flex flex_column choosePartByVin">
  3. <sklineHeader title="选择配件"></sklineHeader>
  4. <!-- 头部车辆信息 -->
  5. <div class="flex align-center cpb_header" v-if="carInfo">
  6. <div>
  7. <image :src="carInfo.icon" style="width: 100rpx;height: 100rpx;border-radius: 10px;background-color: #fff;"></image>
  8. </div>
  9. <div>
  10. <div class="flex align-center">
  11. <div class="carTits ellipsis-two">{{modelLabel||''}}</div>
  12. </div>
  13. <div class="flex align-center">
  14. <div>VIN码:{{vinNumber}}</div>
  15. <div class="copyText" @click="copyVin"><span>复制</span></div>
  16. </div>
  17. </div>
  18. </div>
  19. <!-- 配件列表 -->
  20. <div class="cpb_middle flex">
  21. <div class="slider-bar">
  22. <scroll-view type="list" style="width:100%;height:100%;" scroll-y>
  23. <view class="tabs-item" :class="[curLeve2 == 'all' ? 'active' : '']" @click="selLeve2('all')">
  24. 全部
  25. </view>
  26. <view class="tabs-item" :class="[curLeve2 == item.id ? 'active' : '']" v-for="(item, index) in leve2Data" :key="index" @click="selLeve2(item.id)">
  27. {{item.label}}
  28. </view>
  29. </scroll-view>
  30. </div>
  31. <div class="right-list">
  32. <scroll-view
  33. class="right-list-content"
  34. scroll-y
  35. type="custom"
  36. @scrolltolower="onreachBottom">
  37. <!-- vin适配配件 -->
  38. <sticky-section>
  39. <sticky-header>
  40. <view class="nav-right-title">适配推荐</view>
  41. </sticky-header>
  42. <list-view>
  43. <vinPartItem
  44. v-for="(item,index) in vinPartList"
  45. :key="index"
  46. :list="item"
  47. :commonPartCode="commonPartCodeList"
  48. :configPrice="configPrice"
  49. :showCarPrice="showCarPrice"
  50. :showCostPrice="showCostPrice"
  51. :showShelfDetial="showShelfDetial"
  52. :showNonShelfDetial="showNonShelfDetial"
  53. :priceShowVal="priceShowVal"
  54. @viewImg="viewImg"
  55. @openPrice="openPriceModal"
  56. @addPart="addPart"
  57. @updateVinNums="updateVinNums"
  58. ></vinPartItem>
  59. <view v-if="vinPartList&&vinPartList.length==0">
  60. <sklineTemp v-if="vinStatus!='loading'" text="暂无适配推荐"/>
  61. </view>
  62. <view style="padding: 20upx;" v-if="vinStatus=='loading'" >
  63. <uni-load-more :status="vinStatus" />
  64. </view>
  65. </list-view>
  66. </sticky-section>
  67. <!-- 其它配件 -->
  68. <sticky-section>
  69. <sticky-header>
  70. <view class="nav-right-title flex align_center justify_between" @click="showOther=!showOther">
  71. 其它配件
  72. <view class="flex align_center">
  73. {{showOther?'隐藏':'展开'}}
  74. <uni-icons :type="showOther?'arrowup':'arrowdown'" size="22" color="#666"></uni-icons>
  75. </view>
  76. </view>
  77. </sticky-header>
  78. <list-view v-if="showOther">
  79. <otherPartItem
  80. v-for="(item,index) in partList"
  81. :key="index"
  82. :list="item"
  83. :configPrice="configPrice"
  84. :showCarPrice="showCarPrice"
  85. :showCostPrice="showCostPrice"
  86. :showShelfDetial="showShelfDetial"
  87. :priceShowVal="priceShowVal"
  88. @viewImg="viewImg"
  89. @openPrice="openPriceModal"
  90. @addPart="addPart"
  91. @updateNums="updateNums"
  92. ></otherPartItem>
  93. <view v-if="total==0">
  94. <sklineTemp v-if="status!='loading'" :text="noDataText"/>
  95. </view>
  96. <view style="padding: 20upx;" v-if="showOther&&total>0">
  97. <uni-load-more :status="status"/>
  98. </view>
  99. </list-view>
  100. </sticky-section>
  101. </scroll-view>
  102. </div>
  103. </div>
  104. <!-- 底部提交按钮 -->
  105. <sklineFooter></sklineFooter>
  106. <div class="cpb_footer flex align-center flex_column" :style="{zIndex:hideFooter?0:10}">
  107. <view class="flex align-center">
  108. <div>
  109. <div class="cpb_cart" @click="openCart">
  110. <uni-badge type="error" :text="cartNums" :style="{position:'absolute',right:'3px',top:'3px'}" absolute="rightTop" size="small"></uni-badge>
  111. <image style="width: 44rpx;height: 44rpx;" :src="`/pagesA/static/icon_shopping@3x.png`"></image>
  112. </div>
  113. </div>
  114. <view>
  115. <view class="flex align_center" v-if="dealerPhone" @click="callPhone()">
  116. <uni-icons size="18" type="phone" color="dodgerblue"></uni-icons> <view class="btnlink">联系汽配商</view>
  117. </view>
  118. </view>
  119. <div>
  120. <button class="submitBtn" type="warn" size="mini" :loading="saveLoading" @click="submitForm">确认拿货</button>
  121. </div>
  122. </view>
  123. <view :style="{height:safeAreaBottom+'px'}"></view>
  124. </div>
  125. <!-- 已选配件 购物车 -->
  126. <page-container
  127. :show="showCart"
  128. :round="true"
  129. :z-index="5"
  130. position="bottom"
  131. custom-style="height:70%"
  132. @afterleave="closeCart">
  133. <div class="cpb_cart-box">
  134. <div class="cpb_close flex align_center justify_center" @click="showCart=false">
  135. <uni-icons size="26" type="closeempty"></uni-icons>
  136. </div>
  137. <div class="cpb_cart-tit">
  138. 已选配件
  139. </div>
  140. <scroll-view type="list" scroll-y="true" class="cpb_cart-list">
  141. <view class="nav-right-item flex" v-for="(item, index) in partListData" :key="item.productSn">
  142. <view class="uni-col-2">
  143. <u-image :src="item.images ? item.images+'?x-oss-process=image/resize,m_fixed,h_80,w_80,color_ffffff' : '/static/def_imgs.png'" border-radius="30" width="150" height="150" bg-color="#EBEBEB" ></u-image>
  144. </view>
  145. <view class="item-info uni-col-10">
  146. <view class="item-name">
  147. <text class="item-tempPart" v-if="!item.currentInven">急送</text>
  148. <text>{{item.name}}</text>
  149. </view>
  150. <view class="item-detail">
  151. <view class="item-detail-info">
  152. <view class="flex justify_between">
  153. <text class="item-detail-text flex_1">{{item.code}}</text>
  154. <text class="item-detail-text" v-if="item.affiliation!='NON_SHELF'">库存:{{item.currentInven?item.currentInven:0}} {{item.unit}}</text>
  155. </view>
  156. <view class="flex" v-if="item.productTypeSn=='543766811373752320'" style="padding-bottom: 5px;">
  157. <uni-tag :text="item.origCode" inverted :circle="true" type="success"></uni-tag>
  158. </view>
  159. <view class="flex align_center justify_between">
  160. <view class="item-detail-text">
  161. <text class="item-price" :style="{color:!item.price?'#666':''}" v-if="showCarPrice">{{item.price?'¥'+item.price:'暂无价格'}}</text>
  162. <text class="item-price" :style="{color:!item.cost?'#666':''}" v-if="showCostPrice">{{item.cost?'¥'+item.cost:'暂无价格'}}</text>
  163. </view>
  164. <view class="item-detail-text">
  165. <view class="flex align_center qty-box">
  166. <view class="qty-btn" @click="updateCartNums(item.qty-1,'cart_'+item.productSn,item.currentInven||999,1)" :class="(item.qty <= 0)?'qty-disabled':''">-</view>
  167. <view class="qty-num" :style="{width:Number(item.qty).toString().length*8+20+'px'}"><input type="number" @blur="e=>updateCartNums(Number(e.detail.value),'cart_'+item.productSn,item.currentInven||999,0)" :value="item.qty"/></view>
  168. <view class="qty-btn" @click="updateCartNums(item.qty+1,'cart_'+item.productSn,item.currentInven||999,1)" :class="(item.qty >= (item.currentInven||999))?'qty-disabled':''">+</view>
  169. </view>
  170. <!-- <uni-number-box @change="e=>updateCartNums({value:e,index:'cart_'+item.productSn})" v-model="item.qty" :index="'cart_'+item.productSn" :min="0" :max="item.currentInven||999"></uni-number-box> -->
  171. </view>
  172. </view>
  173. </view>
  174. </view>
  175. </view>
  176. </view>
  177. </scroll-view>
  178. <sklineFooter></sklineFooter>
  179. </div>
  180. </page-container>
  181. <!-- 去认证 -->
  182. <uni-popup ref="showPopup" type="center" :is-mask-click="false">
  183. <view class="popu-modal">
  184. <view class="popu-close" @click="$refs.showPopup.close()"><uni-icons type="closeempty" size="28"></uni-icons></view>
  185. <image width="533" height="415" style="width: 533rpx;height: 415rpx;" src="/static/authimg.jpg"></image>
  186. <view style="padding-top:1rem;" class="flex justify_center">
  187. <button @click="toAuthStore()" type="primary" :style="{background:'#066cff',color:'#fff',width:'350rpx',borderRadius:'100px'}">开始认证</button>
  188. </view>
  189. </view>
  190. </uni-popup>
  191. <!-- 价格查看 -->
  192. <uni-popup ref="showPriceModal" type="center">
  193. <view class="show-price-modal popu-modal" v-if="tempData">
  194. <view class="popu-close" @click="closePriceModal"><uni-icons type="closeempty" size="28"></uni-icons></view>
  195. <view class="itemlist">
  196. <text>产品编码</text>
  197. <text>{{tempData.code||'--'}}</text>
  198. </view>
  199. <view class="itemlist" v-if="tempData.productTypeSn=='543766811373752320'">
  200. <text>原厂编码</text>
  201. <text>{{tempData.origCode||'--'}}</text>
  202. </view>
  203. <view class="itemlist">
  204. <text>产品名称</text>
  205. <text>{{tempData.name||'--'}}</text>
  206. </view>
  207. <view v-if="tempData.affiliation=='SHELF'">
  208. <view class="itemlist" v-if="configPrice&&configPrice.shelf_cost_show == '1'">
  209. <text>进货价</text>
  210. <text>{{tempData.cost?'¥'+tempData.cost:'暂无价格'}}</text>
  211. </view>
  212. <view class="itemlist" v-if="configPrice&&configPrice.shelf_price_show == '1'">
  213. <text>车主价</text>
  214. <text>{{tempData.price?'¥'+tempData.price:'暂无价格'}}</text>
  215. </view>
  216. </view>
  217. <view v-else>
  218. <view class="itemlist" v-if="configPrice&&configPrice.non_shelf_cost_show == '1'">
  219. <text>进货价</text>
  220. <text>{{tempData.cost?'¥'+tempData.cost:'暂无价格'}}</text>
  221. </view>
  222. <view class="itemlist" v-if="configPrice&&configPrice.non_shelf_price_show == '1'">
  223. <text>车主价</text>
  224. <text>{{tempData.price?'¥'+tempData.price:'暂无价格'}}</text>
  225. </view>
  226. </view>
  227. </view>
  228. </uni-popup>
  229. </view>
  230. </template>
  231. <script>
  232. import { getShelfProductList, getShelfProductType, queryPartCodeByVin, getShelfQueryList, shelfOrderFlowCreate, findShelfUserParam } from '@/api/shelf'
  233. import { scanVinLogCopy } from '@/api/car'
  234. import vinPartItem from './components/vinPartItem.vue'
  235. import otherPartItem from './components/otherPartItem.vue'
  236. import sklineHeader from '@/components/skline/sklineHeader.vue'
  237. import sklineTemp from '@/components/skline/sklineTemp.vue'
  238. import sklineFooter from '@/components/skline/sklineFooter.vue'
  239. export default {
  240. components:{
  241. vinPartItem,
  242. otherPartItem,
  243. sklineHeader,
  244. sklineTemp,
  245. sklineFooter
  246. },
  247. data() {
  248. return {
  249. showOther: false,
  250. showPriceModal: false,
  251. hideFooter: false,
  252. theme: '',
  253. vinNumber: '',
  254. leve2Data: [], // 二级菜单数据
  255. curLeve2: '', // 当前所选二级菜单
  256. carInfo: null,
  257. status: 'loading',
  258. vinStatus: 'loading',
  259. noDataText: '暂无配件',
  260. pageNo: 1,
  261. pageSize: 20,
  262. total: 0, // 列表总数
  263. noMore: false ,// 没有更多
  264. showCart: false, // 购物车
  265. carList:[], // 车型列表
  266. partList: [], // 配件列表
  267. partListData: [], // 已选配件
  268. vinPartList: [],
  269. vinCode:[],
  270. commonPartCodeList:[],
  271. isIphoneXup: false,
  272. saveLoading: false,
  273. showPopup: false,
  274. priceShowVal: null, // 是否可以查看所有价格
  275. showCarPrice: false, // 显示车主价
  276. showCostPrice: false, // 显示成本价
  277. tempData: null ,// 临时数据
  278. safeAreaBottom:0
  279. }
  280. },
  281. computed:{
  282. modelLabel(){
  283. return this.carInfo&&this.carInfo.text||''
  284. },
  285. cartNums(){
  286. let ret = 0
  287. this.partListData.map(item => {
  288. ret = ret + item.qty
  289. })
  290. return ret
  291. },
  292. totalAmount(){
  293. let ret = 0
  294. for(let i=0;i<this.partListData.length;i++){
  295. const item = this.partListData[i]
  296. ret = ret + ((item.price||0) * item.qty)
  297. }
  298. return ret.toFixed(2)
  299. },
  300. dealerPhone(){
  301. const shelfInfo = this.$store.state.vuex_storeShelf
  302. return shelfInfo&&shelfInfo.contactMobile ? shelfInfo.contactMobile : ''
  303. },
  304. userInfo(){
  305. return this.$store.state.vuex_userInfo
  306. },
  307. storeApply(){
  308. return this.$store.state.vuex_storeAuthInfo || null
  309. },
  310. isAdmin(){
  311. return this.userInfo.superAdmin == 1
  312. },
  313. hasRedPacket(){
  314. const rule = this.$store.state.vuex_rewardRule
  315. return rule&&rule.ruleStatus == 'release'
  316. },
  317. configPrice(){
  318. return this.$store.state.vuex_configPrice
  319. },
  320. showShelfDetial(){
  321. return this.configPrice && this.configPrice.shelf_price_show == '1'&&this.configPrice.shelf_cost_show == '1'
  322. },
  323. showNonShelfDetial(){
  324. return this.configPrice && this.configPrice.non_shelf_price_show == '1'&&this.configPrice.non_shelf_cost_show == '1'
  325. }
  326. },
  327. onLoad(opts) {
  328. this.safeAreaBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
  329. this.theme = getApp().globalData.theme
  330. this.vinNumber = opts.vinNumber
  331. this.carInfo = opts.carList?JSON.parse(decodeURIComponent(opts.carList)):null
  332. // 获取vin 对应code
  333. this.getCarCodeByVin()
  334. // 记录
  335. if(opts.type == 'log'){
  336. this.scanVinLogCopy()
  337. }
  338. // 游客
  339. if(this.userInfo.sysUserFlag == '0'){
  340. // 未认证
  341. if(!this.storeApply || this.storeApply&&!this.storeApply.auditStatus){
  342. this.$refs.showPopup.open()
  343. this.hideFooter = true
  344. }
  345. }
  346. },
  347. onUnload() {
  348. this.carList = null
  349. this.partList = null// 配件列表
  350. this.partListData = null // 已选配件
  351. this.vinPartList = null
  352. this.vinCode = null
  353. this.commonPartCodeList = null
  354. },
  355. onShow() {
  356. this.$store.state.vuex_shelfChoosePart = []
  357. this.getShowPriceType()
  358. },
  359. methods: {
  360. getShowPriceType(){
  361. const storeShelf = this.$store.state.vuex_storeShelf
  362. if(storeShelf){
  363. findShelfUserParam({shelfSn: storeShelf?storeShelf.shelfSn:''}).then(res => {
  364. this.priceShowVal = res.data ? res.data.carOwnerPrice == '1' && res.data.purchasesPrice == '1' : false
  365. // 选中了2中价格,则从列表显示价格中取值
  366. if(this.priceShowVal){
  367. // 进货价
  368. this.showCostPrice = res.data.priceShowType == 'PURCHASES_PRICE'
  369. // 车主价
  370. this.showCarPrice = res.data.priceShowType == 'CAR_OWNER_PRICE'
  371. }else{
  372. // 进货价
  373. this.showCostPrice = res.data ? res.data.purchasesPrice == '1' : false
  374. // 车主价
  375. this.showCarPrice = res.data ? res.data.carOwnerPrice == '1' : false
  376. }
  377. })
  378. }else{
  379. this.priceShowVal = false
  380. this.showCostPrice = false
  381. this.showCarPrice = false
  382. }
  383. },
  384. // 打开价格信息弹框
  385. openPriceModal(row,type,show){
  386. console.log(row)
  387. if(this.priceShowVal&&show){
  388. if(type == 0){
  389. row.affiliation = "SHELF"
  390. }
  391. this.tempData = row
  392. this.$refs.showPriceModal.open()
  393. this.hideFooter = true
  394. }
  395. },
  396. // 关闭价格弹框
  397. closePriceModal(){
  398. this.$refs.showPriceModal.close()
  399. this.hideFooter = false
  400. },
  401. // 扫描记录
  402. scanVinLogCopy(){
  403. scanVinLogCopy({id:this.carInfo.id}).then(res => {
  404. console.log(res)
  405. })
  406. },
  407. // 去认证
  408. toAuthStore(){
  409. this.$refs.showPopup.close()
  410. uni.redirectTo({
  411. url: '/pages/storeManage/storeAuth'
  412. })
  413. },
  414. // 联系经销商
  415. callPhone() {
  416. if(this.dealerPhone!=''){
  417. uni.makePhoneCall({
  418. phoneNumber: this.dealerPhone
  419. })
  420. }
  421. },
  422. // 查看产品图片
  423. viewImg(item){
  424. uni.previewImage({
  425. urls: [item.images]
  426. })
  427. },
  428. // 复制
  429. copyVin(){
  430. uni.setClipboardData({
  431. data: this.vinNumber||'',
  432. })
  433. },
  434. // 格式化标签数据和配件分类数据一样
  435. labelToPart(data){
  436. let arr = []
  437. data.map(item => {
  438. arr.push({
  439. id: item.id || item.productTypeSn,
  440. label: item.name
  441. })
  442. })
  443. return arr
  444. },
  445. getCarCodeByVin(){
  446. queryPartCodeByVin({vinNumber:this.vinNumber}).then(res => {
  447. console.log(res,'this.vinCode')
  448. const ret = res.data
  449. this.commonPartCodeList = ret.commonPartCodeList || []
  450. this.vinCode = this.commonPartCodeList.concat(ret.partCodeList||[])
  451. this.getShelfProductType()
  452. })
  453. },
  454. // 获取数字货架分类作为二级分类
  455. getShelfProductType(){
  456. const storeShelf = this.$store.state.vuex_storeShelf
  457. getShelfProductType({
  458. codeList: this.vinCode,
  459. shelfSn: storeShelf?storeShelf.shelfSn:''
  460. }).then(res => {
  461. // console.log(res,'getShelfProductType')
  462. this.leve2Data = this.labelToPart(res.data || [])
  463. // 默认该车适用或全部
  464. this.selLeve2('all')
  465. })
  466. },
  467. // 单击二级菜单
  468. selLeve2 (v) {
  469. this.pageNo = 1
  470. this.partList = []
  471. this.vinPartList = []
  472. this.curLeve2 = v
  473. if(this.vinNumber){
  474. this.getVinShelfPartList()
  475. }
  476. this.getShelfProductList()
  477. },
  478. // 获取数字货架其它配件列表
  479. getShelfProductList(){
  480. const _this = this
  481. let params = {
  482. pageNo: this.pageNo,
  483. pageSize: this.pageSize,
  484. excludeCodeList: this.vinCode,
  485. productTypeSn: this.curLeve2 == 'all' ? '' : this.curLeve2
  486. }
  487. _this.status = 'loading'
  488. getShelfProductList(params).then(res => {
  489. uni.hideLoading()
  490. if(res.status == 200){
  491. _this.total = Number(res.data.count)
  492. if(_this.total>0){
  493. const list = res.data.list || []
  494. // 追加数据
  495. _this.partList.push(_this.fiterChecked(list))
  496. // 判断是否最后一页
  497. const maxPages = Math.ceil(_this.total / _this.pageSize)
  498. if(this.pageNo >= maxPages){
  499. _this.status = 'noMore'
  500. _this.noDataText = '没有更多了'
  501. }
  502. }else{
  503. _this.partList = []
  504. _this.status = 'noMore'
  505. _this.noDataText = '暂无配件'
  506. }
  507. }else{
  508. _this.status = 'more'
  509. _this.partList = []
  510. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  511. }
  512. })
  513. },
  514. // 根据客户vin查询该车可用数字货架中的配件
  515. getVinShelfPartList(){
  516. let params = {
  517. queryWord: this.queryWord,
  518. productTypeSn: this.curLeve2 == 'all' ? '' : this.curLeve2,
  519. codeList: this.vinCode
  520. }
  521. uni.showLoading({
  522. title: '加载中',
  523. mask: true
  524. })
  525. this.vinStatus = 'loading'
  526. getShelfQueryList(params).then(res => {
  527. const ret = this.fiterChecked(res.data || [])
  528. for(let i=0;i<ret.length;i=i+this.pageSize){
  529. this.vinPartList.push(ret.slice(i,(i+this.pageSize)>ret.length?ret.length:(i+this.pageSize)))
  530. }
  531. this.vinStatus = 'noMore'
  532. uni.hideLoading()
  533. })
  534. },
  535. // 过滤已选择的
  536. fiterChecked (list){
  537. this.partListData.forEach(item => {
  538. let p = list.find(k => {
  539. return k.productSn == item.productSn
  540. })
  541. if (p){
  542. p.checked = true
  543. p.qty = item.qty
  544. }
  545. })
  546. return list
  547. },
  548. // 加载更多
  549. onreachBottom () {
  550. if(this.partList.length < this.total && this.showOther){
  551. this.pageNo++
  552. this.getShelfProductList()
  553. }else{
  554. this.status = "noMore"
  555. }
  556. },
  557. // 根据productSn查找
  558. getItemById(sn,type){
  559. const a = this[type].findIndex(k => k.find(s=> s.productSn == sn))
  560. const b = a>=0 ? this[type][a].findIndex(s=> s.productSn == sn) : -1
  561. return {p:a,s:b}
  562. },
  563. // 更新页面列表数量状态
  564. updateListData(sn,type,qty,checked){
  565. const row = this.getItemById(sn,type)
  566. if(row.p>=0 && row.s>=0){
  567. this[type][row.p][row.s].checked = checked
  568. this[type][row.p][row.s].qty = qty
  569. this[type][row.p].splice()
  570. }
  571. },
  572. // 添加到购物车
  573. addPart(item,type){
  574. if(type == 'vin'){
  575. this.updateListData(item.productSn,'vinPartList',1,true)
  576. }else{
  577. this.updateListData(item.productSn,'partList',1,true)
  578. }
  579. // 已选列表
  580. this.partListData.unshift({
  581. id: item.id,
  582. productSn: item.productSn,
  583. name: item.name,
  584. unit: item.unit,
  585. price: item.price,
  586. cost: item.cost,
  587. currentInven: item.currentInven,
  588. code: item.code,
  589. origCode: item.origCode,
  590. qty: 1,
  591. productTypeSn: item.productTypeSn,
  592. images: item.images,
  593. checked: true,
  594. affiliation: item.affiliation
  595. })
  596. },
  597. // 更新配件列表数量
  598. updatePartList(data,type){
  599. const index = this.partListData.findIndex(item => item.productSn == data.index)
  600. // 删除
  601. if(!data.value){
  602. // 删除页面上的数量
  603. this.updateListData(data.index,type,0,false)
  604. // 删除已选列表
  605. if(index>=0){
  606. this.partListData.splice(index,1)
  607. }
  608. // 没有已选,关闭弹框
  609. if(this.partListData.length==0){
  610. this.showCart = false
  611. }
  612. }else{
  613. // 更新数量
  614. this.partListData[index].qty = data.value
  615. this.partListData.splice()
  616. // 更新页面数据
  617. this.updateListData(data.index,type,data.value,true)
  618. }
  619. },
  620. // 修改适配配件上数量
  621. updateVinNums(data){
  622. console.log(data)
  623. this.updatePartList(data,'vinPartList')
  624. },
  625. // 修改其它配件上的数量
  626. updateNums(data){
  627. console.log(data)
  628. this.updatePartList(data,'partList')
  629. },
  630. // 点击购物车修改数量
  631. updateCartNums(value,sn,max,type){
  632. if(!value){
  633. // 删除
  634. const index = this.partListData.findIndex(item => 'cart_'+item.productSn == sn)
  635. if(index>=0){
  636. this.partListData.splice(index,1)
  637. }
  638. if(this.partListData.length==0){
  639. this.showCart = false
  640. }
  641. }else{
  642. const row = this.partListData.find(item => 'cart_'+item.productSn == sn)
  643. const v = value > max ? max : value
  644. if(value > max && type == 0){
  645. if(row){
  646. row.qty = Number(value)
  647. this.$nextTick(()=>{
  648. row.qty = Number(v)
  649. })
  650. }
  651. }else{
  652. row.qty = Number(v)
  653. }
  654. }
  655. // 同步更新Vin适配配件列表上的
  656. this.updateListData(sn.split('_')[1],'vinPartList',Number(v),!!v)
  657. // 同步更新其它配件列表上的
  658. this.updateListData(sn.split('_')[1],'partList',Number(v),!!v)
  659. },
  660. // 打开购物车
  661. openCart(){
  662. if(this.partListData.length){
  663. this.showCart=!this.showCart
  664. }else{
  665. uni.showToast({
  666. icon: 'none',
  667. title: '请选择配件'
  668. })
  669. }
  670. },
  671. // 关闭购物车
  672. closeCart(){
  673. this.showCart = false
  674. },
  675. // 格式化数据
  676. formatData(){
  677. const partList = []
  678. const tempList = []
  679. this.partListData.map(item => {
  680. if(item.currentInven){
  681. partList.push({
  682. "productSn": item.productSn,
  683. "totalQty": item.qty
  684. })
  685. }else{
  686. tempList.push({
  687. "productSn": item.productSn,
  688. "qty": item.qty,
  689. // "price": item.cost
  690. })
  691. }
  692. })
  693. return [partList,tempList]
  694. },
  695. // 立即提交
  696. submitForm(){
  697. // 游客去认证
  698. if(this.userInfo.sysUserFlag == '0'){
  699. // 未认证
  700. if(!this.storeApply || this.storeApply&&(!this.storeApply.auditStatus || this.storeApply.auditStatus == 'REFUSE')){
  701. this.$refs.showPopup.open()
  702. this.hideFooter = true
  703. }
  704. // 认证通过
  705. if(this.storeApply&&this.storeApply.auditStatus=='WAIT'){
  706. uni.showModal({
  707. title: '提示',
  708. content: '门店认证资料审核中,请耐心等待!',
  709. confirmText: '好的',
  710. showCancel: false
  711. })
  712. }
  713. }else{
  714. const storeShelf = this.$store.state.vuex_storeShelf
  715. if(!storeShelf){
  716. uni.showToast({
  717. icon: 'none',
  718. title: '您还未开通数字货架,暂时无法使用'
  719. })
  720. return
  721. }
  722. // 已认证用户
  723. if(this.partListData.length==0){
  724. uni.showToast({
  725. icon: 'none',
  726. title: '请选择配件'
  727. })
  728. return
  729. }
  730. // 开始提交
  731. const params = {
  732. shelfOrderDetailList: this.formatData()[0],
  733. tempBillDetailList: this.formatData()[1],
  734. vin: this.vinNumber,
  735. vehicleModel: this.modelLabel || '',
  736. vehicleLogo: this.carInfo.icon||'',
  737. billSource: 'vin'
  738. }
  739. console.log(params,'立即提交')
  740. this.saveLoading = true
  741. shelfOrderFlowCreate(params).then(res => {
  742. console.log(res,'shelfOrderFlowCreate')
  743. if(res.status == 200){
  744. this.$store.state.vuex_tempData = res.data
  745. // 提交成功
  746. uni.redirectTo({
  747. url:"/pagesA/digitalShelf/choosePartResult?state=1"
  748. })
  749. }else{
  750. this.$store.state.vuex_tempData = {shelfOrder:{remindMessage:res.message}}
  751. // 或失败
  752. uni.redirectTo({
  753. url:"/pagesA/digitalShelf/choosePartResult?state=0"
  754. })
  755. }
  756. this.saveLoading = false
  757. })
  758. }
  759. },
  760. }
  761. }
  762. </script>
  763. <style lang="less">
  764. @import '/flex.css';
  765. .choosePartByVin{
  766. height: 100vh;
  767. .cpb_header{
  768. background-color: #FFFFFF;
  769. padding: 10rpx;
  770. align-items: center;
  771. > div{
  772. padding: 10rpx;
  773. align-items: center;
  774. &:first-child{
  775. padding-right: 20rpx;
  776. }
  777. > div{
  778. &:first-child{
  779. padding-right: 20rpx;
  780. flex-grow: 1;
  781. color: #818b94;
  782. font-size: 24rpx;
  783. }
  784. }
  785. }
  786. .copyText{
  787. background-color: #EBEBEB;
  788. border-radius: 100rpx;
  789. padding: 0 20rpx;
  790. color: #033692;
  791. font-size: 20rpx;
  792. display: flex;
  793. align-items: center;
  794. justify-content: center;
  795. margin-left: 20rpx;
  796. }
  797. .carTits{
  798. font-size: 32rpx;
  799. font-weight: bold;
  800. color: #222222;
  801. line-height: normal;
  802. margin-bottom: 10rpx;
  803. flex-grow: 1;
  804. }
  805. .qhbtns{
  806. display: flex;
  807. align-items: center;
  808. justify-content: center;
  809. font-size: 20rpx;
  810. color: #0485F6;
  811. border:2rpx solid #0485F6;
  812. border-radius: 50rpx;
  813. background: rgba(88, 177, 255, 0.2);
  814. width: 200rpx;
  815. height: 36rpx;
  816. margin-left: 10rpx;
  817. }
  818. }
  819. .popu-modal{
  820. width: 300px;
  821. padding: 30px 20px;
  822. background-color: #fff;
  823. border-radius: 15px;
  824. position: relative;
  825. .popu-close{
  826. position: absolute;
  827. right: 6px;
  828. top: 6px;
  829. width: 30px;
  830. height: 30px;
  831. display: flex;
  832. align-items: center;
  833. justify-content: center;
  834. }
  835. .popu-title{
  836. font-size: 18px;
  837. font-weight: bold;
  838. color: #333;
  839. text-align: center;
  840. margin-bottom: 20px;
  841. }
  842. }
  843. .show-price-modal{
  844. .itemlist{
  845. display: flex;
  846. align-items: center;
  847. justify-content: space-between;
  848. > text{
  849. &:last-child{
  850. color: #999;
  851. width: 70%;
  852. display: block;
  853. }
  854. }
  855. border-bottom: 1px solid #eee;
  856. padding: 10px;
  857. }
  858. }
  859. .cpb_middle{
  860. flex-grow: 1;
  861. padding-top: 4rpx;
  862. overflow: auto;
  863. .slider-bar{
  864. width: 25%;
  865. background: #F5F6F7;
  866. height: 100%;
  867. .tabs-item{
  868. border-left: 6rpx solid #F5F6F7;
  869. padding: 20rpx 10rpx;
  870. font-size: 28rpx;
  871. color: #666E75;
  872. text-align: center;
  873. }
  874. .active{
  875. border-color: #0485F6;
  876. color: #0485F6;
  877. background: #fff;
  878. }
  879. }
  880. .right-list{
  881. position: relative;
  882. flex-grow: 1;
  883. background: #fff;
  884. height: 100%;
  885. width: 75%;
  886. .right-list-content{
  887. height: 100%;
  888. .nav-right-title{
  889. font-weight: bold;
  890. padding: 20upx 25upx;
  891. border-bottom: 2rpx solid #eee;
  892. background: #fff;
  893. > view{
  894. color: #9E9E9E;
  895. font-weight: normal;
  896. }
  897. }
  898. }
  899. }
  900. }
  901. .cpb_footer{
  902. background-color: #fff;
  903. align-items: center;
  904. justify-content: space-between;
  905. z-index: 10;
  906. position: fixed;
  907. width: 100%;
  908. left: 0;
  909. bottom: 0;
  910. .btnlink{
  911. font-size: 14px;
  912. color: #3390e2;
  913. }
  914. > view{
  915. width: 100%;
  916. &:first-child{
  917. padding: 0 20rpx;
  918. justify-content: space-between;
  919. height: 50px;
  920. align-items: center;
  921. .submitBtn{
  922. width: 140rpx;
  923. border-radius: 100rpx;
  924. height: 36px;
  925. }
  926. }
  927. }
  928. .cpb_cart{
  929. width: 84rpx;
  930. height: 84rpx;
  931. background-color: #0485F6;
  932. border-radius: 200rpx;
  933. display: flex;
  934. align-items: center;
  935. justify-content: center;
  936. position: relative;
  937. }
  938. > div{
  939. &:last-child{
  940. width: 40%;
  941. }
  942. }
  943. }
  944. .cpb_cart-box{
  945. background-color: #fff;
  946. width: 100%;
  947. height: 100%;
  948. padding: 0;
  949. border-radius: 30rpx 30rpx 0 0;
  950. display: flex;
  951. flex-direction: column;
  952. .cpb_close{
  953. position: absolute;
  954. top: 3rpx;
  955. right: 15rpx;
  956. width: 70rpx;
  957. height: 70rpx;
  958. font-size: 32rpx;
  959. color: #999;
  960. z-index: 100;
  961. }
  962. .cpb_cart-tit{
  963. text-align: center;
  964. padding: 20rpx;
  965. font-size: 36rpx;
  966. border-bottom: 1px solid #eee;
  967. }
  968. .qty-box{
  969. display: flex;
  970. .qty-btn{
  971. display: flex;
  972. align-items: center;
  973. justify-content: center;
  974. width: 22px;
  975. height: 22px;
  976. border-radius: 50px;
  977. font-size: 18px;
  978. background-color: #066cff;
  979. color: #fff;
  980. &.qty-disabled{
  981. background-color: #c0c0c0;
  982. }
  983. }
  984. .qty-num{
  985. width: 25px;
  986. height: 22px;
  987. line-height: 22px;
  988. padding:0 3px;
  989. input{
  990. width: 100%;
  991. height: 100%;
  992. text-align: center;
  993. color: #333;
  994. }
  995. }
  996. }
  997. .cpb_cart-list{
  998. flex-grow: 1;
  999. .nav-right-item{
  1000. padding: 10px;
  1001. border-bottom:2rpx solid #eee;
  1002. }
  1003. .item-name{
  1004. font-size: 30rpx;
  1005. .item-tempPart{
  1006. background: #0055ff;
  1007. color: #fff;
  1008. border-radius: 1em;
  1009. font-size: 0.8em;
  1010. padding: 0 0.5em;
  1011. }
  1012. }
  1013. .item-info{
  1014. flex-grow: 1;
  1015. padding-left: 10px;
  1016. width: 80%;
  1017. }
  1018. .item-detail{
  1019. .item-detail-info{
  1020. padding: 10upx 0 4upx;
  1021. /deep/ .uni-tag{
  1022. word-break: break-all;
  1023. font-size: 28rpx;
  1024. color: #0fab04eee;
  1025. border: 0;
  1026. padding: 0.2rem 0.3rem;
  1027. }
  1028. > view{
  1029. padding-bottom: 10rpx;
  1030. align-items: center;
  1031. .item-detail-text{
  1032. color: #999;
  1033. .phtxt{
  1034. color: #0485F6;
  1035. font-size: 28upx;
  1036. }
  1037. .item-price{
  1038. color: #FB1E1E;
  1039. font-size: 28upx;
  1040. }
  1041. }
  1042. }
  1043. }
  1044. }
  1045. }
  1046. }
  1047. }
  1048. </style>