choosePart.vue 27 KB

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