choosePart.vue 29 KB

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