choosePart.vue 28 KB

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