choosePart.vue 29 KB

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