choosePart.vue 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  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. shelfPlaceCode: item.shelfPlaceCode
  612. })
  613. },
  614. // 更新配件列表数量
  615. updatePartList(data,type){
  616. console.log(data,type)
  617. const index = this.partListData.findIndex(item => item.productSn == data.index)
  618. // 删除
  619. if(!data.value){
  620. // 删除页面上的数量
  621. this.updateListData(data.index,type,0,false)
  622. // 删除已选列表
  623. if(index>=0){
  624. this.partListData.splice(index,1)
  625. }
  626. // 没有已选,关闭弹框
  627. if(this.partListData.length==0){
  628. this.showCart = false
  629. }
  630. }else{
  631. // 更新数量
  632. this.partListData[index].qty = data.value
  633. this.partListData.splice()
  634. // 更新页面数据
  635. this.updateListData(data.index,type,data.value,true)
  636. }
  637. if(data.event){
  638. // this.$refs.cartAnimation.touchOnGoods(data.event,this.busPos);
  639. }
  640. },
  641. // 修改适配配件上数量
  642. updateVinNums(data){
  643. this.updatePartList(data,'vinPartList')
  644. },
  645. // 修改其它配件上的数量
  646. updateNums(data){
  647. this.updatePartList(data,'partList')
  648. },
  649. // 点击购物车修改数量
  650. updateCartNums(value,sn,max,type){
  651. if(!value){
  652. // 删除
  653. const index = this.partListData.findIndex(item => 'cart_'+item.productSn == sn)
  654. if(index>=0){
  655. this.partListData.splice(index,1)
  656. }
  657. if(this.partListData.length==0){
  658. this.showCart = false
  659. }
  660. }else{
  661. const row = this.partListData.find(item => 'cart_'+item.productSn == sn)
  662. const v = value > max ? max : value
  663. if(value > max && type == 0){
  664. if(row){
  665. row.qty = Number(value)
  666. this.$nextTick(()=>{
  667. row.qty = Number(v)
  668. })
  669. }
  670. }else{
  671. row.qty = Number(v)
  672. }
  673. }
  674. // 同步更新Vin适配配件列表上的
  675. this.updateListData(sn.split('_')[1],'vinPartList',Number(value),!!value)
  676. // 同步更新其它配件列表上的
  677. this.updateListData(sn.split('_')[1],'partList',Number(value),!!value)
  678. },
  679. // 打开购物车
  680. openCart(){
  681. if(this.partListData.length){
  682. this.showCart=!this.showCart
  683. }else{
  684. uni.showToast({
  685. icon: 'none',
  686. title: '请选择配件'
  687. })
  688. }
  689. },
  690. // 关闭购物车
  691. closeCart(){
  692. this.showCart = false
  693. },
  694. // 格式化数据
  695. formatData(){
  696. const partList = []
  697. const tempList = []
  698. this.partListData.map(item => {
  699. if(item.currentInven){
  700. partList.push({
  701. "productSn": item.productSn,
  702. "totalQty": item.qty
  703. })
  704. }else{
  705. tempList.push({
  706. "productSn": item.productSn,
  707. "qty": item.qty,
  708. // "price": item.cost
  709. })
  710. }
  711. })
  712. return [partList,tempList]
  713. },
  714. // 立即提交
  715. submitForm(){
  716. // 游客去认证
  717. if(this.userInfo.sysUserFlag == '0'){
  718. // 未认证
  719. if(!this.storeApply || this.storeApply&&(!this.storeApply.auditStatus || this.storeApply.auditStatus == 'REFUSE')){
  720. this.$refs.showPopup.open()
  721. this.hideFooter = true
  722. }
  723. // 认证通过
  724. if(this.storeApply&&this.storeApply.auditStatus=='WAIT'){
  725. uni.showModal({
  726. title: '提示',
  727. content: '门店认证资料审核中,请耐心等待!',
  728. confirmText: '好的',
  729. showCancel: false
  730. })
  731. }
  732. }else{
  733. const storeShelf = this.$store.state.vuex_storeShelf
  734. if(!storeShelf){
  735. uni.showToast({
  736. icon: 'none',
  737. title: '您还未开通数字货架,暂时无法使用'
  738. })
  739. return
  740. }
  741. // 已认证用户
  742. if(this.partListData.length==0){
  743. uni.showToast({
  744. icon: 'none',
  745. title: '请选择配件'
  746. })
  747. return
  748. }
  749. // 开始提交
  750. const params = {
  751. shelfOrderDetailList: this.formatData()[0],
  752. tempBillDetailList: this.formatData()[1],
  753. vin: this.vinNumber,
  754. vehicleModel: this.modelLabel || '',
  755. vehicleLogo: this.carInfo.icon||'',
  756. billSource: 'vin'
  757. }
  758. console.log(params,'立即提交')
  759. this.saveLoading = true
  760. shelfOrderFlowCreate(params).then(res => {
  761. console.log(res,'shelfOrderFlowCreate')
  762. if(res.status == 200){
  763. this.$store.state.vuex_tempData = res.data
  764. // 提交成功
  765. uni.redirectTo({
  766. url:"/pagesA/digitalShelf/choosePartResult?state=1"
  767. })
  768. }else{
  769. this.$store.state.vuex_tempData = {shelfOrder:{remindMessage:res.message}}
  770. // 或失败
  771. uni.redirectTo({
  772. url:"/pagesA/digitalShelf/choosePartResult?state=0"
  773. })
  774. }
  775. this.saveLoading = false
  776. })
  777. }
  778. },
  779. }
  780. }
  781. </script>
  782. <style lang="less">
  783. @import '/flex.css';
  784. .choosePartByVin{
  785. height: 100vh;
  786. .cpb_header{
  787. background-color: #FFFFFF;
  788. padding: 10rpx;
  789. align-items: center;
  790. > div{
  791. padding: 10rpx;
  792. align-items: center;
  793. &:first-child{
  794. padding-right: 20rpx;
  795. }
  796. > div{
  797. &:first-child{
  798. padding-right: 20rpx;
  799. flex-grow: 1;
  800. color: #818b94;
  801. font-size: 24rpx;
  802. }
  803. }
  804. }
  805. .copyText{
  806. background-color: #EBEBEB;
  807. border-radius: 100rpx;
  808. padding: 0 20rpx;
  809. color: #033692;
  810. font-size: 20rpx;
  811. display: flex;
  812. align-items: center;
  813. justify-content: center;
  814. margin-left: 20rpx;
  815. }
  816. .carTits{
  817. font-size: 32rpx;
  818. font-weight: bold;
  819. color: #222222;
  820. line-height: normal;
  821. margin-bottom: 10rpx;
  822. flex-grow: 1;
  823. }
  824. .qhbtns{
  825. display: flex;
  826. align-items: center;
  827. justify-content: center;
  828. font-size: 20rpx;
  829. color: #0485F6;
  830. border:2rpx solid #0485F6;
  831. border-radius: 50rpx;
  832. background: rgba(88, 177, 255, 0.2);
  833. width: 200rpx;
  834. height: 36rpx;
  835. margin-left: 10rpx;
  836. }
  837. }
  838. .popu-modal{
  839. width: 300px;
  840. padding: 30px 20px;
  841. background-color: #fff;
  842. border-radius: 15px;
  843. position: relative;
  844. .popu-close{
  845. position: absolute;
  846. right: 6px;
  847. top: 6px;
  848. width: 30px;
  849. height: 30px;
  850. display: flex;
  851. align-items: center;
  852. justify-content: center;
  853. }
  854. .popu-title{
  855. font-size: 18px;
  856. font-weight: bold;
  857. color: #333;
  858. text-align: center;
  859. margin-bottom: 20px;
  860. }
  861. }
  862. .show-price-modal{
  863. .itemlist{
  864. display: flex;
  865. align-items: center;
  866. justify-content: space-between;
  867. > text{
  868. &:last-child{
  869. color: #999;
  870. width: 70%;
  871. display: block;
  872. }
  873. }
  874. border-bottom: 1px solid #eee;
  875. padding: 10px;
  876. }
  877. }
  878. .cpb_middle{
  879. flex-grow: 1;
  880. padding-top: 4rpx;
  881. overflow: auto;
  882. .slider-bar{
  883. width: 25%;
  884. background: #F5F6F7;
  885. height: 100%;
  886. .tabs-item{
  887. border-left: 6rpx solid #F5F6F7;
  888. padding: 20rpx 10rpx;
  889. font-size: 28rpx;
  890. color: #666E75;
  891. text-align: center;
  892. }
  893. .active{
  894. border-color: #0485F6;
  895. color: #0485F6;
  896. background: #fff;
  897. }
  898. }
  899. .right-list{
  900. position: relative;
  901. flex-grow: 1;
  902. background: #fff;
  903. height: 100%;
  904. width: 75%;
  905. .right-list-content{
  906. height: 100%;
  907. .nav-right-title{
  908. font-weight: bold;
  909. padding: 20upx 25upx;
  910. border-bottom: 2rpx solid #eee;
  911. background: #fff;
  912. > view{
  913. color: #9E9E9E;
  914. font-weight: normal;
  915. }
  916. }
  917. }
  918. }
  919. }
  920. .cpb_footer{
  921. background-color: #fff;
  922. align-items: center;
  923. justify-content: space-between;
  924. z-index: 10;
  925. position: fixed;
  926. width: 100%;
  927. left: 0;
  928. bottom: 0;
  929. .btnlink{
  930. font-size: 14px;
  931. color: #3390e2;
  932. }
  933. > view{
  934. width: 100%;
  935. &:first-child{
  936. padding: 0 20rpx;
  937. justify-content: space-between;
  938. height: 50px;
  939. align-items: center;
  940. .submitBtn{
  941. padding: 0 10px;
  942. border-radius: 100rpx;
  943. height: 35px;
  944. }
  945. }
  946. }
  947. .cpb_cart{
  948. width: 84rpx;
  949. height: 84rpx;
  950. background-color: #0485F6;
  951. border-radius: 200rpx;
  952. display: flex;
  953. align-items: center;
  954. justify-content: center;
  955. position: relative;
  956. }
  957. > div{
  958. &:last-child{
  959. width: 40%;
  960. }
  961. }
  962. }
  963. .cpb_cart-box{
  964. background-color: #fff;
  965. width: 100%;
  966. height: 100%;
  967. padding: 0;
  968. border-radius: 30rpx 30rpx 0 0;
  969. display: flex;
  970. flex-direction: column;
  971. .cpb_close{
  972. position: absolute;
  973. top: 3rpx;
  974. right: 15rpx;
  975. width: 70rpx;
  976. height: 70rpx;
  977. font-size: 32rpx;
  978. color: #999;
  979. z-index: 100;
  980. }
  981. .cpb_cart-tit{
  982. text-align: center;
  983. padding: 20rpx;
  984. font-size: 36rpx;
  985. border-bottom: 1px solid #eee;
  986. }
  987. .qty-box{
  988. display: flex;
  989. .qty-btn{
  990. display: flex;
  991. align-items: center;
  992. justify-content: center;
  993. width: 22px;
  994. height: 22px;
  995. border-radius: 50px;
  996. font-size: 18px;
  997. background-color: #066cff;
  998. color: #fff;
  999. &.qty-disabled{
  1000. background-color: #c0c0c0;
  1001. }
  1002. }
  1003. .qty-num{
  1004. width: 25px;
  1005. height: 22px;
  1006. line-height: 22px;
  1007. padding:0 3px;
  1008. input{
  1009. width: 100%;
  1010. height: 100%;
  1011. text-align: center;
  1012. color: #333;
  1013. }
  1014. }
  1015. }
  1016. .cpb_cart-list{
  1017. flex-grow: 1;
  1018. .nav-right-item{
  1019. padding: 10px;
  1020. border-bottom:2rpx solid #eee;
  1021. }
  1022. .item-name{
  1023. font-size: 30rpx;
  1024. display: flex;
  1025. align-items: center;
  1026. .item-tempPart{
  1027. background: #F44336;
  1028. color: #fff;
  1029. border-radius: 6px;
  1030. font-size: 20rpx;
  1031. padding: 0 5px;
  1032. display: inline-block;
  1033. margin-right: 5px;
  1034. }
  1035. .item-name-text{
  1036. width:50%;
  1037. flex-grow: 1;
  1038. }
  1039. }
  1040. .item-info{
  1041. flex-grow: 1;
  1042. padding-left: 10px;
  1043. width: 80%;
  1044. }
  1045. .item-detail{
  1046. .item-detail-info{
  1047. padding: 10upx 0 4upx;
  1048. ::v-deep .uni-tag{
  1049. word-break: break-all;
  1050. font-size: 24rpx;
  1051. padding: 0.2rem 0.3rem;
  1052. }
  1053. > view{
  1054. padding-bottom: 10rpx;
  1055. align-items: center;
  1056. .item-detail-text{
  1057. color: #999;
  1058. .phtxt{
  1059. color: #0485F6;
  1060. font-size: 28upx;
  1061. }
  1062. .item-price{
  1063. color: #FB1E1E;
  1064. font-size: 28upx;
  1065. }
  1066. }
  1067. }
  1068. }
  1069. }
  1070. }
  1071. }
  1072. }
  1073. </style>