choosePart.vue 29 KB

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