choosePart.vue 30 KB

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