choosePart.vue 27 KB

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