choosePart.vue 28 KB

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