choosePart.vue 27 KB

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