choosePart.vue 29 KB

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