choosePart.vue 30 KB

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