choosePart.vue 30 KB

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