choosePart.vue 27 KB

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