choosePart.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  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">{{isTire?item.origCode: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">{{isTire?item.origCode: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">{{isTire?item.origCode: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. isTire(){
  272. const a = this.leve2Data.find(item => item.id == this.curLeve2)
  273. return a && a.label.indexOf("轮胎")>=0
  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. },
  308. onLoad(opts) {
  309. this.theme = getApp().globalData.theme
  310. this.vinNumber = opts.vinNumber
  311. this.carInfo = opts.carList?JSON.parse(decodeURIComponent(opts.carList)):null
  312. // 获取vin 对应code
  313. this.getCarCodeByVin()
  314. // 记录
  315. if(opts.type == 'log'){
  316. this.scanVinLogCopy()
  317. }
  318. // 游客
  319. if(this.userInfo.sysUserFlag == '0'){
  320. // 未认证
  321. if(!this.storeApply || this.storeApply&&!this.storeApply.auditStatus){
  322. this.showPopup = true
  323. }
  324. }
  325. },
  326. onShow() {
  327. this.$store.state.vuex_shelfChoosePart = []
  328. this.getShowPriceType()
  329. },
  330. methods: {
  331. getShowPriceType(){
  332. const storeShelf = this.$store.state.vuex_storeShelf
  333. findShelfUserParam({shelfSn: storeShelf?storeShelf.shelfSn:''}).then(res => {
  334. this.priceShowVal = res.data ? res.data.carOwnerPrice == '1' && res.data.purchasesPrice == '1' : false
  335. // 选中了2中价格,则从列表显示价格中取值
  336. if(this.priceShowVal){
  337. // 进货价
  338. this.showCostPrice = res.data.priceShowType == 'PURCHASES_PRICE'
  339. // 车主价
  340. this.showCarPrice = res.data.priceShowType == 'CAR_OWNER_PRICE'
  341. }else{
  342. // 进货价
  343. this.showCostPrice = res.data ? res.data.purchasesPrice == '1' : false
  344. // 车主价
  345. this.showCarPrice = res.data ? res.data.carOwnerPrice == '1' : false
  346. }
  347. })
  348. },
  349. // 打开价格信息弹框
  350. openPriceModal(row,type){
  351. console.log(row)
  352. if(this.priceShowVal){
  353. if(type == 0){
  354. row.affiliation = "SHELF"
  355. }
  356. this.tempData = row
  357. this.showPriceModal = true
  358. }
  359. },
  360. scanVinLogCopy(){
  361. scanVinLogCopy({id:this.carInfo.id}).then(res => {
  362. console.log(res)
  363. })
  364. },
  365. toAuthStore(){
  366. this.showPopup = false
  367. uni.redirectTo({
  368. url: '/pages/storeManage/storeAuth'
  369. })
  370. },
  371. callPhone() {
  372. if(this.dealerPhone!=''){
  373. uni.makePhoneCall({
  374. phoneNumber: this.dealerPhone
  375. })
  376. }
  377. },
  378. viewImg(item){
  379. uni.previewImage({
  380. urls: [item.images]
  381. })
  382. },
  383. // 复制
  384. copyVin(){
  385. uni.setClipboardData({
  386. data: this.vinNumber||'',
  387. })
  388. },
  389. // 格式化标签数据和配件分类数据一样
  390. labelToPart(data){
  391. let arr = []
  392. data.map(item => {
  393. arr.push({
  394. id: item.id || item.productTypeSn,
  395. label: item.name
  396. })
  397. })
  398. return arr
  399. },
  400. getCarCodeByVin(){
  401. queryPartCodeByVin({vinNumber:this.vinNumber}).then(res => {
  402. console.log(res,'this.vinCode')
  403. const ret = res.data
  404. this.commonPartCodeList = ret.commonPartCodeList || []
  405. this.vinCode = this.commonPartCodeList.concat(ret.partCodeList||[])
  406. this.getShelfProductType()
  407. })
  408. },
  409. // 获取数字货架分类作为二级分类
  410. getShelfProductType(){
  411. const storeShelf = this.$store.state.vuex_storeShelf
  412. getShelfProductType({
  413. codeList: this.vinCode,
  414. shelfSn: storeShelf?storeShelf.shelfSn:''
  415. }).then(res => {
  416. console.log(res,'getShelfProductType')
  417. this.leve2Data = this.labelToPart(res.data || [])
  418. // 默认该车适用或全部
  419. this.selLeve2('all')
  420. })
  421. },
  422. // 单击二级菜单
  423. selLeve2 (v) {
  424. this.pageNo = 1
  425. this.partList = []
  426. this.vinPartList = []
  427. this.curLeve2 = v
  428. if(this.vinNumber){
  429. this.getVinShelfPartList()
  430. }
  431. this.getShelfProductList()
  432. },
  433. // 获取数字货架配件列表
  434. getShelfProductList(){
  435. const _this = this
  436. let params = {
  437. pageNo: this.pageNo,
  438. pageSize: this.pageSize,
  439. excludeCodeList: this.vinCode,
  440. productTypeSn: this.curLeve2 == 'all' ? '' : this.curLeve2
  441. }
  442. _this.status = 'loading'
  443. getShelfProductList(params).then(res => {
  444. console.log(res,'获取数字货架配件列表')
  445. uni.hideLoading()
  446. if(res.status == 200){
  447. let list = res.data.list
  448. if (list && list.length){
  449. // 分页 拼接数据
  450. if (_this.pageNo != 1) {
  451. _this.partList = _this.partList ? _this.partList.concat(this.fiterChecked(list)) : this.fiterChecked(list)
  452. } else {
  453. _this.partList = this.fiterChecked(list)
  454. }
  455. this.total = res.data.count
  456. if (_this.partList.length == res.data.count) {
  457. _this.status = 'nomore'
  458. } else {
  459. _this.status = 'loadmore'
  460. }
  461. } else {
  462. _this.partList = list || []
  463. this.total = 0
  464. _this.status = 'nomore'
  465. }
  466. _this.noDataText = '暂无配件'
  467. }else{
  468. _this.status = 'loadmore'
  469. _this.partList = []
  470. this.total = 0
  471. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  472. }
  473. })
  474. },
  475. // 根据客户vin查询该车可用数字货架中的配件
  476. getVinShelfPartList(){
  477. let params = {
  478. queryWord: this.queryWord,
  479. productTypeSn: this.curLeve2 == 'all' ? '' : this.curLeve2,
  480. codeList: this.vinCode
  481. }
  482. this.vinStatus = 'loading'
  483. getShelfQueryList(params).then(res => {
  484. this.vinPartList = this.fiterChecked(res.data || [])
  485. this.vinStatus = 'nomore'
  486. })
  487. },
  488. // 过滤已选择的
  489. fiterChecked (list){
  490. this.partListData.map(item => {
  491. let p = list.find(k => {
  492. return k.productSn == item.productSn
  493. })
  494. if (p){
  495. p.checked = true
  496. p.qty = item.qty
  497. }
  498. })
  499. return list
  500. },
  501. // 加载更多
  502. onreachBottom () {
  503. if(this.partList.length < this.total && this.showOther){
  504. this.pageNo++
  505. this.getShelfProductList()
  506. }else{
  507. this.status = "nomore"
  508. }
  509. },
  510. // 添加到购物车
  511. addPart(item){
  512. item.checked = true
  513. item.qty = 1
  514. this.partListData.unshift({
  515. id: item.id,
  516. productSn: item.productSn,
  517. name: item.name,
  518. unit: item.unit,
  519. price: item.price,
  520. cost: item.cost,
  521. currentInven: item.currentInven,
  522. code: item.code,
  523. qty: item.qty,
  524. images: item.images,
  525. checked: true,
  526. affiliation: item.affiliation
  527. })
  528. },
  529. // 更新配件列表数量
  530. updatePartList(data,type){
  531. const prow = this[type].find(item => item.productSn == data.index)
  532. const index = this.partListData.findIndex(item => item.productSn == data.index)
  533. // 删除
  534. if(!data.value){
  535. prow.checked = false
  536. if(index>=0){
  537. this.partListData.splice(index,1)
  538. }
  539. if(this.partListData.length==0){
  540. this.showCart = false
  541. }
  542. }else{
  543. this.partListData[index].qty = data.value
  544. this.partListData.splice()
  545. }
  546. },
  547. // 修改适配配件上数量
  548. updateVinNums(data){
  549. this.updatePartList(data,'vinPartList')
  550. },
  551. // 修改其它配件上的数量
  552. updateNums(data){
  553. this.updatePartList(data,'partList')
  554. },
  555. // 点击购物车修改数量
  556. updateCartNums(data){
  557. console.log(data)
  558. if(!data.value){
  559. const index = this.partListData.findIndex(item => 'cart_'+item.productSn == data.index)
  560. if(index>=0){
  561. this.partListData.splice(index,1)
  562. }
  563. if(this.partListData.length==0){
  564. this.showCart = false
  565. }
  566. }
  567. // 同步更新Vin适配配件列表上的
  568. const vinprow = this.vinPartList.find(item => 'cart_'+item.productSn == data.index)
  569. if(vinprow){
  570. vinprow.qty = data.value
  571. vinprow.checked = !!data.value
  572. this.vinPartList.splice()
  573. }
  574. // 同步更新其它配件列表上的
  575. const prow = this.partList.find(item => 'cart_'+item.productSn == data.index)
  576. if(prow){
  577. prow.qty = data.value
  578. prow.checked = !!data.value
  579. this.partList.splice()
  580. }
  581. },
  582. // 打开购物车
  583. openCart(){
  584. if(this.partListData.length){
  585. this.showCart=!this.showCart
  586. }else{
  587. uni.showToast({
  588. icon: 'none',
  589. title: '请选择配件'
  590. })
  591. }
  592. },
  593. // 格式化数据
  594. formatData(){
  595. const partList = []
  596. const tempList = []
  597. this.partListData.map(item => {
  598. if(item.currentInven){
  599. partList.push({
  600. "productSn": item.productSn,
  601. "totalQty": item.qty
  602. })
  603. }else{
  604. tempList.push({
  605. "productSn": item.productSn,
  606. "qty": item.qty,
  607. // "price": item.cost
  608. })
  609. }
  610. })
  611. return [partList,tempList]
  612. },
  613. // 立即提交
  614. submitForm(){
  615. // 游客去认证
  616. if(this.userInfo.sysUserFlag == '0'){
  617. // 未认证
  618. if(!this.storeApply || this.storeApply&&(!this.storeApply.auditStatus || this.storeApply.auditStatus == 'REFUSE')){
  619. this.showPopup = true
  620. }
  621. // 认证通过
  622. if(this.storeApply&&this.storeApply.auditStatus=='WAIT'){
  623. uni.showModal({
  624. title: '提示',
  625. content: '门店认证资料审核中,请耐心等待!',
  626. confirmText: '好的',
  627. showCancel: false
  628. })
  629. }
  630. }else{
  631. // 已认证用户
  632. if(this.partListData.length==0){
  633. uni.showToast({
  634. icon: 'none',
  635. title: '请选择配件'
  636. })
  637. return
  638. }
  639. // 开始提交
  640. const params = {
  641. shelfOrderDetailList: this.formatData()[0],
  642. tempBillDetailList: this.formatData()[1],
  643. vin: this.vinNumber,
  644. vehicleModel: this.modelLabel || '',
  645. vehicleLogo: this.carInfo.icon||'',
  646. billSource: 'vin'
  647. }
  648. console.log(params,'立即提交')
  649. this.saveLoading = true
  650. shelfOrderFlowCreate(params).then(res => {
  651. console.log(res,'shelfOrderFlowCreate')
  652. if(res.status == 200){
  653. // 提交成功
  654. uni.redirectTo({
  655. url:"/pagesA/digitalShelf/choosePartResult?data="+encodeURIComponent(JSON.stringify(res.data))+"&state=1"
  656. })
  657. }else{
  658. // 或失败
  659. uni.redirectTo({
  660. url:"/pagesA/digitalShelf/choosePartResult?data="+encodeURIComponent(JSON.stringify({shelfOrder:{remindMessage:res.message}}))+"&state=0"
  661. })
  662. }
  663. this.saveLoading = false
  664. })
  665. }
  666. },
  667. }
  668. }
  669. </script>
  670. <style lang="less">
  671. .choosePartByVin{
  672. height: 100vh;
  673. .cpb_header{
  674. background-color: #FFFFFF;
  675. padding: 10rpx;
  676. align-items: center;
  677. > div{
  678. padding: 10rpx;
  679. align-items: center;
  680. &:first-child{
  681. padding-right: 20rpx;
  682. }
  683. > div{
  684. &:first-child{
  685. padding-right: 20rpx;
  686. flex-grow: 1;
  687. color: #818b94;
  688. font-size: 24rpx;
  689. }
  690. }
  691. }
  692. .copyText{
  693. background-color: #EBEBEB;
  694. border-radius: 100rpx;
  695. padding: 0 20rpx;
  696. color: #033692;
  697. font-size: 20rpx;
  698. display: flex;
  699. align-items: center;
  700. justify-content: center;
  701. margin-left: 20rpx;
  702. }
  703. .carTits{
  704. font-size: 32rpx;
  705. font-weight: bold;
  706. color: #222222;
  707. line-height: normal;
  708. margin-bottom: 10rpx;
  709. flex-grow: 1;
  710. }
  711. .qhbtns{
  712. display: flex;
  713. align-items: center;
  714. justify-content: center;
  715. font-size: 20rpx;
  716. color: #0485F6;
  717. border:2rpx solid #0485F6;
  718. border-radius: 50rpx;
  719. background: rgba(88, 177, 255, 0.2);
  720. width: 200rpx;
  721. height: 36rpx;
  722. margin-left: 10rpx;
  723. }
  724. }
  725. .show-price-modal{
  726. padding: 30px 20px;
  727. >view{
  728. display: flex;
  729. align-items: center;
  730. justify-content: space-between;
  731. > text{
  732. &:last-child{
  733. color: #999;
  734. width: 70%;
  735. display: block;
  736. }
  737. }
  738. border-bottom: 1px solid #eee;
  739. padding: 10px;
  740. }
  741. }
  742. .cpb_middle{
  743. flex-grow: 1;
  744. padding-top: 10rpx;
  745. overflow: auto;
  746. .slider-bar{
  747. width: 25%;
  748. background: #F5F6F7;
  749. height: 100%;
  750. overflow: auto;
  751. .tabs{
  752. > view{
  753. border-left: 6rpx solid #F5F6F7;
  754. padding: 30rpx 10rpx;
  755. font-size: 30rpx;
  756. color: #666E75;
  757. }
  758. .active{
  759. border-color: #0485F6;
  760. color: #0485F6;
  761. background: #fff;
  762. }
  763. }
  764. }
  765. .right-list{
  766. position: relative;
  767. flex-grow: 1;
  768. background: #fff;
  769. height: 100%;
  770. width: 75%;
  771. .right-list-content{
  772. height: 100%;
  773. .nav-right-title{
  774. font-weight: bold;
  775. padding: 20upx 25upx;
  776. border-bottom: 2rpx solid #eee;
  777. > text{
  778. color: #9E9E9E;
  779. font-weight: normal;
  780. }
  781. }
  782. .nav-right-item{
  783. padding: 15upx 25upx;
  784. border-bottom: 2rpx solid #f5f5f5;
  785. .item-info{
  786. padding-left: 20upx;
  787. flex-grow: 1;
  788. .item-name{
  789. font-size: 32upx;
  790. color: #191919;
  791. display: flex;
  792. align-items: center;
  793. >image{
  794. width: 38rpx;
  795. height: 38rpx;
  796. margin-right: 10rpx;
  797. }
  798. >text{
  799. flex: 1;
  800. word-break: break-all;
  801. }
  802. }
  803. .item-detail{
  804. .item-detail-info{
  805. padding: 10upx 0 4upx;
  806. > view{
  807. padding-bottom: 10rpx;
  808. align-items: center;
  809. .item-detail-text{
  810. color: #999;
  811. .phtxt{
  812. color: #0485F6;
  813. font-size: 28upx;
  814. }
  815. .item-price{
  816. color: #FB1E1E;
  817. font-size: 28upx;
  818. }
  819. }
  820. }
  821. }
  822. }
  823. }
  824. }
  825. }
  826. }
  827. }
  828. .cpb_footer{
  829. padding: 20rpx;
  830. background-color: #fff;
  831. align-items: center;
  832. justify-content: space-between;
  833. .cpb_cart{
  834. width: 84rpx;
  835. height: 84rpx;
  836. background-color: #0485F6;
  837. border-radius: 200rpx;
  838. display: flex;
  839. align-items: center;
  840. justify-content: center;
  841. position: relative;
  842. }
  843. > div{
  844. &:last-child{
  845. width: 40%;
  846. }
  847. }
  848. }
  849. .cpb_cart-mask{
  850. position: fixed;
  851. width: 100%;
  852. background: rgba(0,0,0,0.5);
  853. z-index: 900;
  854. bottom: 120rpx;
  855. top: 0;
  856. }
  857. .cpb_cart-box{
  858. background-color: #fff;
  859. position: absolute;
  860. width: 100%;
  861. z-index: 1000;
  862. bottom: 0;
  863. padding: 20rpx 0;
  864. border-radius: 30rpx 30rpx 0 0;
  865. max-height: 70vh;
  866. display: flex;
  867. flex-direction: column;
  868. .cpb_close{
  869. position: absolute;
  870. top: 20rpx;
  871. right: 20rpx;
  872. width: 70rpx;
  873. height: 70rpx;
  874. font-size: 32rpx;
  875. color: #999;
  876. }
  877. .cpb_cart-tit{
  878. text-align: center;
  879. padding: 20rpx;
  880. font-size: 36rpx;
  881. }
  882. .cpb_cart-list{
  883. padding: 20rpx 30rpx;
  884. overflow: auto;
  885. flex-grow: 1;
  886. > view{
  887. margin-bottom: 30rpx;
  888. }
  889. .item-name{
  890. font-size: 32rpx;
  891. .item-tempPart{
  892. background: #0055ff;
  893. color: #fff;
  894. border-radius: 1em;
  895. font-size: 0.8em;
  896. padding: 0 0.5em;
  897. }
  898. }
  899. .item-info{
  900. border-bottom:2rpx solid #f8f8f8;
  901. flex-grow: 1;
  902. padding-left: 0.8em;
  903. }
  904. .item-detail{
  905. .item-detail-info{
  906. padding: 10upx 0 4upx;
  907. > view{
  908. padding-bottom: 30rpx;
  909. align-items: center;
  910. .item-detail-text{
  911. color: #999;
  912. .phtxt{
  913. color: #0485F6;
  914. font-size: 28upx;
  915. }
  916. .item-price{
  917. color: #FB1E1E;
  918. font-size: 28upx;
  919. }
  920. }
  921. }
  922. }
  923. }
  924. }
  925. }
  926. }
  927. </style>