choosePart.vue 28 KB

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