choosePart.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943
  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="isTire">
  52. <text class="item-detail-text">原厂编码:</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="isTire">
  112. <text class="item-detail-text">原厂编码:</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="isTire" style="padding-bottom: 5px;">
  188. <text class="item-detail-text">原厂编码:</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>
  228. <text>产品名称</text>
  229. <text>{{tempData.name||'--'}}</text>
  230. </view>
  231. <view v-if="tempData.affiliation=='SHELF'">
  232. <text>进货价</text>
  233. <text>{{tempData.cost?'¥'+tempData.cost:'暂无价格'}}</text>
  234. </view>
  235. <view>
  236. <text>车主价</text>
  237. <text>{{tempData.price?'¥'+tempData.price:'暂无价格'}}</text>
  238. </view>
  239. </view>
  240. </u-popup>
  241. </view>
  242. </template>
  243. <script>
  244. import { getShelfProductList, getShelfProductType, queryPartCodeByVin, getShelfQueryList, shelfOrderFlowCreate, findShelfUserParam } from '@/api/shelf'
  245. import { scanVinLogCopy } from '@/api/car'
  246. export default {
  247. data() {
  248. return {
  249. showOther: false,
  250. showPriceModal: false,
  251. theme: '',
  252. vinNumber: '',
  253. leve2Data: [], // 二级菜单数据
  254. curLeve2: '', // 当前所选二级菜单
  255. carInfo: null,
  256. status: 'loading',
  257. vinStatus: 'loading',
  258. noDataText: '暂无配件',
  259. pageNo: 1,
  260. pageSize: 10,
  261. total: 0, // 列表总数
  262. noMore: false ,// 没有更多
  263. showCart: false, // 购物车
  264. carList:[], // 车型列表
  265. partList: [], // 配件列表
  266. partListData: [], // 已选配件
  267. vinPartList: [],
  268. vinCode:[],
  269. commonPartCodeList:[],
  270. isIphoneXup: false,
  271. saveLoading: false,
  272. showPopup: false,
  273. priceShowVal: null, // 是否可以查看所有价格
  274. showCarPrice: false, // 显示车主价
  275. showCostPrice: false, // 显示成本价
  276. tempData: null // 临时数据
  277. }
  278. },
  279. computed:{
  280. modelLabel(){
  281. return this.carInfo&&this.carInfo.text||''
  282. },
  283. isTire(){
  284. const a = this.leve2Data.find(item => item.id == this.curLeve2)
  285. return a && a.label.indexOf("轮胎")>=0
  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. images: item.images,
  538. checked: true,
  539. affiliation: item.affiliation
  540. })
  541. },
  542. // 更新配件列表数量
  543. updatePartList(data,type){
  544. const prow = this[type].find(item => item.productSn == data.index)
  545. const index = this.partListData.findIndex(item => item.productSn == data.index)
  546. // 删除
  547. if(!data.value){
  548. prow.checked = false
  549. if(index>=0){
  550. this.partListData.splice(index,1)
  551. }
  552. if(this.partListData.length==0){
  553. this.showCart = false
  554. }
  555. }else{
  556. this.partListData[index].qty = data.value
  557. this.partListData.splice()
  558. }
  559. },
  560. // 修改适配配件上数量
  561. updateVinNums(data){
  562. this.updatePartList(data,'vinPartList')
  563. },
  564. // 修改其它配件上的数量
  565. updateNums(data){
  566. this.updatePartList(data,'partList')
  567. },
  568. // 点击购物车修改数量
  569. updateCartNums(data){
  570. console.log(data)
  571. if(!data.value){
  572. const index = this.partListData.findIndex(item => 'cart_'+item.productSn == data.index)
  573. if(index>=0){
  574. this.partListData.splice(index,1)
  575. }
  576. if(this.partListData.length==0){
  577. this.showCart = false
  578. }
  579. }
  580. // 同步更新Vin适配配件列表上的
  581. const vinprow = this.vinPartList.find(item => 'cart_'+item.productSn == data.index)
  582. if(vinprow){
  583. vinprow.qty = data.value
  584. vinprow.checked = !!data.value
  585. this.vinPartList.splice()
  586. }
  587. // 同步更新其它配件列表上的
  588. const prow = this.partList.find(item => 'cart_'+item.productSn == data.index)
  589. if(prow){
  590. prow.qty = data.value
  591. prow.checked = !!data.value
  592. this.partList.splice()
  593. }
  594. },
  595. // 打开购物车
  596. openCart(){
  597. if(this.partListData.length){
  598. this.showCart=!this.showCart
  599. }else{
  600. uni.showToast({
  601. icon: 'none',
  602. title: '请选择配件'
  603. })
  604. }
  605. },
  606. // 格式化数据
  607. formatData(){
  608. const partList = []
  609. const tempList = []
  610. this.partListData.map(item => {
  611. if(item.currentInven){
  612. partList.push({
  613. "productSn": item.productSn,
  614. "totalQty": item.qty
  615. })
  616. }else{
  617. tempList.push({
  618. "productSn": item.productSn,
  619. "qty": item.qty,
  620. // "price": item.cost
  621. })
  622. }
  623. })
  624. return [partList,tempList]
  625. },
  626. // 立即提交
  627. submitForm(){
  628. // 游客去认证
  629. if(this.userInfo.sysUserFlag == '0'){
  630. // 未认证
  631. if(!this.storeApply || this.storeApply&&(!this.storeApply.auditStatus || this.storeApply.auditStatus == 'REFUSE')){
  632. this.showPopup = true
  633. }
  634. // 认证通过
  635. if(this.storeApply&&this.storeApply.auditStatus=='WAIT'){
  636. uni.showModal({
  637. title: '提示',
  638. content: '门店认证资料审核中,请耐心等待!',
  639. confirmText: '好的',
  640. showCancel: false
  641. })
  642. }
  643. }else{
  644. // 已认证用户
  645. if(this.partListData.length==0){
  646. uni.showToast({
  647. icon: 'none',
  648. title: '请选择配件'
  649. })
  650. return
  651. }
  652. // 开始提交
  653. const params = {
  654. shelfOrderDetailList: this.formatData()[0],
  655. tempBillDetailList: this.formatData()[1],
  656. vin: this.vinNumber,
  657. vehicleModel: this.modelLabel || '',
  658. vehicleLogo: this.carInfo.icon||'',
  659. billSource: 'vin'
  660. }
  661. console.log(params,'立即提交')
  662. this.saveLoading = true
  663. shelfOrderFlowCreate(params).then(res => {
  664. console.log(res,'shelfOrderFlowCreate')
  665. if(res.status == 200){
  666. // 提交成功
  667. uni.redirectTo({
  668. url:"/pagesA/digitalShelf/choosePartResult?data="+encodeURIComponent(JSON.stringify(res.data))+"&state=1"
  669. })
  670. }else{
  671. // 或失败
  672. uni.redirectTo({
  673. url:"/pagesA/digitalShelf/choosePartResult?data="+encodeURIComponent(JSON.stringify({shelfOrder:{remindMessage:res.message}}))+"&state=0"
  674. })
  675. }
  676. this.saveLoading = false
  677. })
  678. }
  679. },
  680. }
  681. }
  682. </script>
  683. <style lang="less">
  684. .choosePartByVin{
  685. height: 100vh;
  686. .cpb_header{
  687. background-color: #FFFFFF;
  688. padding: 10rpx;
  689. align-items: center;
  690. > div{
  691. padding: 10rpx;
  692. align-items: center;
  693. &:first-child{
  694. padding-right: 20rpx;
  695. }
  696. > div{
  697. &:first-child{
  698. padding-right: 20rpx;
  699. flex-grow: 1;
  700. color: #818b94;
  701. font-size: 24rpx;
  702. }
  703. }
  704. }
  705. .copyText{
  706. background-color: #EBEBEB;
  707. border-radius: 100rpx;
  708. padding: 0 20rpx;
  709. color: #033692;
  710. font-size: 20rpx;
  711. display: flex;
  712. align-items: center;
  713. justify-content: center;
  714. margin-left: 20rpx;
  715. }
  716. .carTits{
  717. font-size: 32rpx;
  718. font-weight: bold;
  719. color: #222222;
  720. line-height: normal;
  721. margin-bottom: 10rpx;
  722. flex-grow: 1;
  723. }
  724. .qhbtns{
  725. display: flex;
  726. align-items: center;
  727. justify-content: center;
  728. font-size: 20rpx;
  729. color: #0485F6;
  730. border:2rpx solid #0485F6;
  731. border-radius: 50rpx;
  732. background: rgba(88, 177, 255, 0.2);
  733. width: 200rpx;
  734. height: 36rpx;
  735. margin-left: 10rpx;
  736. }
  737. }
  738. .show-price-modal{
  739. padding: 30px 20px;
  740. >view{
  741. display: flex;
  742. align-items: center;
  743. justify-content: space-between;
  744. > text{
  745. &:last-child{
  746. color: #999;
  747. width: 70%;
  748. display: block;
  749. }
  750. }
  751. border-bottom: 1px solid #eee;
  752. padding: 10px;
  753. }
  754. }
  755. .cpb_middle{
  756. flex-grow: 1;
  757. padding-top: 10rpx;
  758. overflow: auto;
  759. .slider-bar{
  760. width: 25%;
  761. background: #F5F6F7;
  762. height: 100%;
  763. overflow: auto;
  764. .tabs{
  765. > view{
  766. border-left: 6rpx solid #F5F6F7;
  767. padding: 30rpx 10rpx;
  768. font-size: 30rpx;
  769. color: #666E75;
  770. }
  771. .active{
  772. border-color: #0485F6;
  773. color: #0485F6;
  774. background: #fff;
  775. }
  776. }
  777. }
  778. .right-list{
  779. position: relative;
  780. flex-grow: 1;
  781. background: #fff;
  782. height: 100%;
  783. width: 75%;
  784. .right-list-content{
  785. height: 100%;
  786. .nav-right-title{
  787. font-weight: bold;
  788. padding: 20upx 25upx;
  789. border-bottom: 2rpx solid #eee;
  790. > text{
  791. color: #9E9E9E;
  792. font-weight: normal;
  793. }
  794. }
  795. .nav-right-item{
  796. padding: 15upx 25upx;
  797. border-bottom: 2rpx solid #f5f5f5;
  798. .item-info{
  799. padding-left: 20upx;
  800. flex-grow: 1;
  801. .item-name{
  802. font-size: 32upx;
  803. color: #191919;
  804. display: flex;
  805. align-items: center;
  806. >image{
  807. width: 38rpx;
  808. height: 38rpx;
  809. margin-right: 10rpx;
  810. }
  811. >text{
  812. flex: 1;
  813. word-break: break-all;
  814. }
  815. }
  816. .item-detail{
  817. .item-detail-info{
  818. padding: 10upx 0 4upx;
  819. > view{
  820. padding-bottom: 10rpx;
  821. align-items: center;
  822. .item-detail-text{
  823. color: #999;
  824. .phtxt{
  825. color: #0485F6;
  826. font-size: 28upx;
  827. }
  828. .item-price{
  829. color: #FB1E1E;
  830. font-size: 28upx;
  831. }
  832. }
  833. }
  834. }
  835. }
  836. }
  837. }
  838. }
  839. }
  840. }
  841. .cpb_footer{
  842. padding: 20rpx;
  843. background-color: #fff;
  844. align-items: center;
  845. justify-content: space-between;
  846. .cpb_cart{
  847. width: 84rpx;
  848. height: 84rpx;
  849. background-color: #0485F6;
  850. border-radius: 200rpx;
  851. display: flex;
  852. align-items: center;
  853. justify-content: center;
  854. position: relative;
  855. }
  856. > div{
  857. &:last-child{
  858. width: 40%;
  859. }
  860. }
  861. }
  862. .cpb_cart-mask{
  863. position: fixed;
  864. width: 100%;
  865. background: rgba(0,0,0,0.5);
  866. z-index: 900;
  867. bottom: 120rpx;
  868. top: 0;
  869. }
  870. .cpb_cart-box{
  871. background-color: #fff;
  872. position: absolute;
  873. width: 100%;
  874. z-index: 1000;
  875. bottom: 0;
  876. padding: 20rpx 0;
  877. border-radius: 30rpx 30rpx 0 0;
  878. max-height: 70vh;
  879. display: flex;
  880. flex-direction: column;
  881. .cpb_close{
  882. position: absolute;
  883. top: 20rpx;
  884. right: 20rpx;
  885. width: 70rpx;
  886. height: 70rpx;
  887. font-size: 32rpx;
  888. color: #999;
  889. }
  890. .cpb_cart-tit{
  891. text-align: center;
  892. padding: 20rpx;
  893. font-size: 36rpx;
  894. }
  895. .cpb_cart-list{
  896. padding: 20rpx 30rpx;
  897. overflow: auto;
  898. flex-grow: 1;
  899. > view{
  900. margin-bottom: 30rpx;
  901. }
  902. .item-name{
  903. font-size: 32rpx;
  904. .item-tempPart{
  905. background: #0055ff;
  906. color: #fff;
  907. border-radius: 1em;
  908. font-size: 0.8em;
  909. padding: 0 0.5em;
  910. }
  911. }
  912. .item-info{
  913. border-bottom:2rpx solid #f8f8f8;
  914. flex-grow: 1;
  915. padding-left: 0.8em;
  916. }
  917. .item-detail{
  918. .item-detail-info{
  919. padding: 10upx 0 4upx;
  920. > view{
  921. padding-bottom: 30rpx;
  922. align-items: center;
  923. .item-detail-text{
  924. color: #999;
  925. .phtxt{
  926. color: #0485F6;
  927. font-size: 28upx;
  928. }
  929. .item-price{
  930. color: #FB1E1E;
  931. font-size: 28upx;
  932. }
  933. }
  934. }
  935. }
  936. }
  937. }
  938. }
  939. }
  940. </style>