choosePart.vue 30 KB

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