choosePart.vue 29 KB

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