choosePart.vue 28 KB

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