choosePart.vue 30 KB

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