choosePart.vue 27 KB

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