choosePart.vue 26 KB

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