index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <view class="content">
  3. <view class="header-box">
  4. <UniStatusBar></UniStatusBar>
  5. <view class="title flex align_center" :style="{height:(navHeight+'px')}">
  6. <u-image src="/static/logo-h.png" width="349" height='40'></u-image>
  7. </view>
  8. </view>
  9. <view class="cbody">
  10. <view class="body-box bg-blue">
  11. <!-- 滚动区域 -->
  12. <view class="scroll-list">
  13. <scrollBox v-if="list.length" :list="list"></scrollBox>
  14. </view>
  15. <!-- 保证金 -->
  16. <view class="notices flex align_center" v-if="bondRecord" @click="toPayBondAmount">
  17. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有一笔保证金待支付 ¥{{bondRecord.bondAmount}}</view>
  18. <!-- <text class="text">立即支付>></text> -->
  19. </view>
  20. <!-- 待取货提醒 -->
  21. <view class="notices flex align_center" v-if="!bondRecord&&orderTodo" @click="toOrder">
  22. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有待取货的货架订单哦!</view> <text class="text">立即处理>></text>
  23. </view>
  24. <!-- 门店审核不通过 -->
  25. <view class="notices flex justify_between" v-if="storeApply&&storeApply.auditStatus=='REFUSE'&&storeApply.readFlag=='0'">
  26. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 门店认证资料审核不通过,请重新提交审核!</view> <text class="text" @click="toKnow">知道了</text>
  27. </view>
  28. <!-- 名片 -->
  29. <view class="userCard flex align_center justify_between">
  30. <view class="userCard-info flex align_center">
  31. <view>
  32. <u-image shape='circle' v-if="!hasLogin" src="/static/def_personal_avatar.png" width="90" height="90"></u-image>
  33. <u-image shape='circle' v-else :src="avatarUrl||'/static/def_personal_avatar.png'" width="90" height="90"></u-image>
  34. </view>
  35. <view class="user-info" @click="toUser">
  36. <view v-if="!hasLogin" style="font-size: 40rpx;">
  37. 请点击登录
  38. </view>
  39. <view v-else>
  40. <view class="user-name">{{userInfo.userNameCN || userInfo.mobile}}</view>
  41. <view v-if="hasLogin&&userInfo&&userInfo.sysUserFlag == '0'">
  42. <u-tag text="个人用户" mode="dark" type="warning" shape="circle" size="mini" />
  43. </view>
  44. <view v-else>{{userInfo.orgName}}</view>
  45. </view>
  46. </view>
  47. </view>
  48. <view @click="toUser">
  49. <text v-if="hasLogin&&userInfo&&userInfo.sysUserFlag == '0'" class="user-rz">
  50. {{storeApply&&storeApply.auditStatus=='WAIT'?'认证门店审核中':'认证成为门店'}}
  51. </text>
  52. <u-icon name="arrow-right"></u-icon>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="body-box">
  57. <!-- 扫描按钮 -->
  58. <view class="scanButton flex align_center" @click="openCamera">
  59. <u-icon name="scan" size="60"></u-icon><text class="ml10">扫描VIN</text>
  60. </view>
  61. <!-- 直接取货 -->
  62. <view class="quickButton flex align_center" v-if="userInfo.sysUserFlag == '1'" @click="openTakeGood">
  63. <text>没有VIN,直接取货</text>
  64. </view>
  65. <view class="flex align_center justify_center">
  66. <u-image src="/static/banner1.png" width="645" height="504"></u-image>
  67. </view>
  68. <u-action-sheet :list="actionList" @click="clickAction" v-model="showAction"></u-action-sheet>
  69. </view>
  70. <!-- 扫描记录 -->
  71. <view class="list-box">
  72. <!-- 扫描记录 -->
  73. <u-cell-group :border="false">
  74. <u-cell-item title="VIN查询历史" @click="toAllRecord" :title-style="{fontSize:'1em'}" value="全部">
  75. <u-icon slot="icon" size="38" color="#066cff" style="margin-right: 0.3em;" name="order"></u-icon>
  76. </u-cell-item>
  77. </u-cell-group>
  78. <u-cell-group :border="false" v-if="hasLogin">
  79. <u-cell-item v-for="item in vinList"
  80. @click="toChoosePart(item)"
  81. :key="item.id"
  82. :title="item.vinCode"
  83. :title-style="{fontSize:'1em'}"
  84. :label="userInfo&&userInfo.sysUserFlag == '0' ? item.createDate : (item.brandName +' '+item.modelName)">
  85. <text slot="icon"></text>
  86. </u-cell-item>
  87. <view style="padding: 20upx;">
  88. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="vinList.length==0 && status!='loading'" mode="list"></u-empty>
  89. <u-loadmore v-if="status=='loading'" :status="status" />
  90. </view>
  91. </u-cell-group>
  92. <view class="des" v-if="vinList.length&&hasLogin">仅展示最近5条记录,点击“全部”查看更多</view>
  93. <view class="des" v-if="!hasLogin">请登录后查看历史记录</view>
  94. </view>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. import {
  100. mapState,
  101. mapMutations,
  102. } from 'vuex'
  103. import scrollBox from '@/components/scrollBox.vue'
  104. import UniStatusBar from '@/components/uni-status-bar/uni-status-bar.vue'
  105. import { shelfBondRecordWaitPayRecord, findStoreShelf, shelfGetTotalWaitQty, getProductfindByScanCode, findPriceShow } from '@/api/shelf.js'
  106. import { xprhStoreApplyRead } from '@/api/xprh.js'
  107. import { listLookUp, getLookUpDatas } from '@/api/data.js';
  108. import { scanVinLogQueryRoll, getScanVinLogList, getScanGetMaxQty }from '@/api/car.js'
  109. export default {
  110. components: {
  111. scrollBox,
  112. UniStatusBar
  113. },
  114. data() {
  115. return {
  116. status: 'loading',
  117. noDataText: '暂无数据',
  118. bondRecord: null, // 保证金
  119. list:[],
  120. vinList: [],
  121. orderTodo: null,
  122. avatarUrl:'',
  123. navHeight: '44',
  124. scanMaxNums: 10,
  125. showAction: false,
  126. actionList: [
  127. {
  128. text: '扫描条形码/二维码',
  129. fontSize: 32
  130. },
  131. {
  132. text: '按产品编码查询',
  133. fontSize: 32
  134. }
  135. ]
  136. }
  137. },
  138. computed: {
  139. ...mapState(['hasLogin','vuex_vinScanNums']),
  140. hasShelf(){
  141. return this.$store.state.vuex_storeShelf
  142. },
  143. userInfo(){
  144. return this.$store.state.vuex_userInfo
  145. },
  146. storeApply(){
  147. return this.$store.state.vuex_storeAuthInfo || null
  148. }
  149. },
  150. onReady() {
  151. this.getScrollLog()
  152. // 获取导航栏高度
  153. const res = uni.getSystemInfoSync()
  154. const system = res.platform
  155. if (system === 'android') {
  156. this.navHeight = 48
  157. } else if (system === 'ios') {
  158. this.navHeight = 44
  159. }
  160. },
  161. onLoad() {
  162. this.orderTodo = null
  163. this.bondRecord = null
  164. this.vinList = []
  165. // 检测是否登录
  166. this.$store.dispatch('checkLogin',()=>{
  167. // 获取数据字典
  168. this.getListLookUp();
  169. // 获取支付,收款方式
  170. this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
  171. // 价格类型
  172. this.getLookUpList('PRICE_SHOW_TYPE', 'vuex_priceTypeList');
  173. // 初始化页面
  174. this.pageInit()
  175. })
  176. // 刷新首页数据
  177. uni.$on("refashHome",()=>{
  178. this.pageInit()
  179. })
  180. },
  181. onUnload() {
  182. uni.$off('refashHome')
  183. },
  184. // 下拉刷新
  185. onPullDownRefresh(){
  186. this.pageInit()
  187. setTimeout(function () {
  188. uni.stopPullDownRefresh();
  189. }, 1000);
  190. },
  191. onShareAppMessage() {},
  192. onShow() {
  193. // 用户头像
  194. this.avatarUrl = uni.getStorageSync('userPhoto');
  195. if(this.hasLogin){
  196. // 查询门店认证信息
  197. if(this.userInfo.sysUserFlag == '0'){
  198. this.findLastApply()
  199. }
  200. }
  201. },
  202. methods: {
  203. async getPriceShow(){
  204. await findPriceShow({paramCode:'PRICE_SHOW'}).then(res => {
  205. this.showPrice = res.data ? res.data.paramValue=='1' : false
  206. this.$store.state.vuex_showPrice[0] = this.showPrice
  207. })
  208. await findPriceShow({paramCode:'PRICE_SHOW_TYPE'}).then(res => {
  209. if(res.data&&res.data.paramValue){
  210. this.priceType = res.data.paramValue
  211. this.priceTypeName = this.$store.state.vuex_priceTypeList.find(item => item.code == res.data.paramValue).dispName
  212. this.$store.state.vuex_showPrice[1] = this.priceType
  213. }
  214. })
  215. await findPriceShow({paramCode:'PRICE_SHOW_EMPLOYEE'}).then(res => {
  216. this.showJhPrice = res.data ? res.data.paramValue=='1' : false
  217. this.$store.state.vuex_showPrice[2] = this.showJhPrice
  218. })
  219. },
  220. pageInit(){
  221. if(this.hasLogin){
  222. // 获取扫描记录
  223. this.getVinLog()
  224. // 非游客
  225. if(this.userInfo.sysUserFlag == '1'){
  226. // 查询是否有数字货架
  227. this.getStoreShelf()
  228. }else{
  229. // 获取扫描次数
  230. this.$store.dispatch("getScanNums")
  231. // 获取最大扫描次数
  232. this.getMaxQty()
  233. // 查询门店认证信息
  234. this.findLastApply()
  235. }
  236. }else{
  237. uni.removeStorageSync('token')
  238. }
  239. },
  240. // 获取数据字典
  241. getListLookUp() {
  242. const _this = this;
  243. listLookUp({ pageNo: 1, pageSize: 1000 }).then(res => {
  244. if (res.status == 200) {
  245. _this.$store.state.vuex_allLookUp = res.data;
  246. }
  247. });
  248. },
  249. // 或某一项字典列表,参数code
  250. getLookUpList(code, vuexKey) {
  251. getLookUpDatas({ type: code }).then(res => {
  252. if (res.status == 200) {
  253. this.$store.state[vuexKey] = res.data || [];
  254. if(code=='PRICE_SHOW_TYPE'){
  255. // 获取显示价格类型
  256. this.getPriceShow()
  257. }
  258. }
  259. });
  260. },
  261. // 获取最大扫描数
  262. getMaxQty(){
  263. getScanGetMaxQty().then(res => {
  264. this.scanMaxNums = res.data || 10
  265. this.$store.state.vuex_scanMaxNums = this.scanMaxNums
  266. })
  267. },
  268. // 获取最新申请门店
  269. findLastApply(){
  270. const mobile = this.userInfo.mobile
  271. this.$store.dispatch('getSotreAuth',mobile)
  272. },
  273. // 知道审核不通过
  274. toKnow(){
  275. uni.showLoading({
  276. title: "正在提交"
  277. })
  278. xprhStoreApplyRead({sn:this.storeApply.applySn}).then(res => {
  279. if(res.status == 200){
  280. this.findLastApply()
  281. }
  282. uni.hideLoading()
  283. })
  284. },
  285. // 待取货数量合计
  286. shelfGetTotalWaitQty(){
  287. shelfGetTotalWaitQty({billState:'WAIT'}).then(res => {
  288. if(res.status == 200){
  289. this.orderTodo = res.data;
  290. }
  291. })
  292. },
  293. // 货架订单列表
  294. toOrder(){
  295. if(this.hasShelf){
  296. uni.navigateTo({
  297. url: "/pages/digitalShelf/orderList"
  298. })
  299. }else{
  300. uni.showToast({
  301. icon:'none',
  302. title: '门店没有关联数字货架,无法使用此功能!'
  303. })
  304. }
  305. },
  306. // 获取上方滚动扫描记录
  307. getScrollLog(){
  308. scanVinLogQueryRoll({pageNo:1,pageSize:1000}).then(res => {
  309. console.log(res)
  310. this.list = res.data.list || []
  311. })
  312. },
  313. // 获取当前门店扫描记录
  314. getVinLog(){
  315. this.vinList = []
  316. this.status = "loading"
  317. // VISITOR:游客,EMPLOYEE:雇员
  318. getScanVinLogList({ pageNo:1, pageSize:5, identifyType: this.userInfo.identifyType }).then(res => {
  319. this.vinList = res.data&&res.data.list || []
  320. this.vinList = this.vinList.filter(item => item.vinCode)
  321. this.status = 'nomore'
  322. })
  323. },
  324. // 查询是否支持数字货架
  325. getStoreShelf(){
  326. findStoreShelf().then(res => {
  327. console.log(res)
  328. this.$store.state.vuex_storeShelf = res.data;
  329. if(res.data){
  330. // 保证金查询
  331. this.getShelfBWPayRecord()
  332. // 获取订单信息
  333. this.shelfGetTotalWaitQty()
  334. }
  335. })
  336. },
  337. // 获取保证金金额
  338. getShelfBWPayRecord(){
  339. const data = this.$store.state.vuex_storeShelf
  340. shelfBondRecordWaitPayRecord({shelfSn: data.shelfSn, storeSn: data.storeSn}).then(res => {
  341. console.log(res,'获取保证金金额')
  342. this.bondRecord = res.data
  343. })
  344. },
  345. // 保证金支付
  346. toPayBondAmount(){},
  347. openTakeGood(){
  348. // 已有数字货架
  349. if(this.hasShelf){
  350. this.showAction = true
  351. }else{
  352. uni.showToast({
  353. icon:'none',
  354. title: '门店没有关联数字货架,无法使用此功能!'
  355. })
  356. }
  357. },
  358. // 选择取货方式
  359. clickAction(index){
  360. const shelfSn = this.hasShelf.shelfSn
  361. // 扫描
  362. if(index == 0){
  363. uni.scanCode({
  364. success: function (res) {
  365. console.log(res);
  366. const params = {
  367. codeType: res.scanType == 'QR_CODE' ? 0 : 1,
  368. }
  369. // 二维码
  370. if(res.scanType == 'QR_CODE'){
  371. const ret = res.result.split("&")
  372. params.productSn = ret[2] // 产品编码sn
  373. }else{
  374. params.qrCode = res.result
  375. }
  376. uni.showLoading({
  377. title: "正在查询产品..."
  378. })
  379. // 确认取货
  380. getProductfindByScanCode(params).then(res => {
  381. if(res.status == 200 && res.data){
  382. if(res.data.currentInven){
  383. const params = Object.assign({shelfSn: shelfSn, billSource: res.scanType == 'QR_CODE' ? 'qr_code': 'bar_code'},res.data)
  384. uni.navigateTo({
  385. url: '/pages/queryByCode/confirmQh?data='+ encodeURIComponent(JSON.stringify(res.data))
  386. })
  387. }else{
  388. uni.showModal({
  389. title: '提示',
  390. content: '产品库存为0,无法取货!',
  391. confirmText: '好的',
  392. showCancel: false
  393. })
  394. }
  395. }else{
  396. uni.showModal({
  397. title: '提示',
  398. content: '产品不属于此货架,请重新扫描!',
  399. confirmText: '好的',
  400. showCancel: false
  401. })
  402. }
  403. uni.hideLoading()
  404. })
  405. }
  406. });
  407. }else{
  408. // 按编码搜索
  409. uni.navigateTo({
  410. url: '/pages/queryByCode/queryByCode'
  411. })
  412. }
  413. },
  414. // 去扫描
  415. openCamera(){
  416. if(this.hasLogin){
  417. if(this.userInfo.sysUserFlag == '0'){
  418. if(this.vuex_vinScanNums < this.scanMaxNums){
  419. uni.navigateTo({
  420. url: "/pages/scan-frame/scan-frame"
  421. })
  422. }else{
  423. uni.showModal({
  424. title: '提示',
  425. content: '个人用户扫描VIN仅限10次,您的次数已用完!',
  426. confirmText: '好的',
  427. showCancel: false,
  428. success(res) {}
  429. })
  430. }
  431. }else{
  432. uni.navigateTo({
  433. url: "/pages/scan-frame/scan-frame"
  434. })
  435. }
  436. }else{
  437. uni.navigateTo({
  438. url: '/pages/login/login'
  439. })
  440. }
  441. },
  442. // 查看扫描记录
  443. toAllRecord(){
  444. uni.navigateTo({
  445. url: this.hasLogin ? "/pages/vinRecord/vinRecord" : '/pages/login/login'
  446. })
  447. },
  448. toUser(){
  449. if(this.hasLogin){
  450. // 用户详细信息 或 门店认证
  451. uni.navigateTo({
  452. url: this.userInfo.sysUserFlag == '1' ? '/pages/personData/personData' : '/pages/storeManage/storeAuth'
  453. })
  454. }else{
  455. uni.navigateTo({
  456. url: '/pages/login/login'
  457. })
  458. }
  459. },
  460. toChoosePart(item){
  461. item.text = item.modelInfo
  462. uni.navigateTo({
  463. url: "/pages/digitalShelf/choosePart?vinNumber="+item.vinCode+"&carList="+encodeURIComponent(JSON.stringify(item))
  464. })
  465. }
  466. }
  467. }
  468. </script>
  469. <style lang="less">
  470. .content {
  471. margin: 0;
  472. padding: 0;
  473. height: 100vh;
  474. display: flex;
  475. flex-direction: column;
  476. background-image: linear-gradient(#86defa 0%,#cdeff9 25%,#ffffff 40%);
  477. .header-box{
  478. z-index: 5;
  479. padding: 0em 1em;
  480. background: #066cff;
  481. .title{
  482. padding: 0;
  483. }
  484. }
  485. .cbody{
  486. flex-grow: 1;
  487. overflow-y: auto;
  488. overflow-x: hidden;
  489. }
  490. .body-box{
  491. padding: 0em 1em 0.8em;
  492. z-index: 4;
  493. .notices{
  494. padding: 0.5em 0 0;
  495. font-size: 0.9em;
  496. margin-top: 0.5rem;
  497. view{
  498. color: #ffaf46;
  499. max-width: 80%;
  500. }
  501. .text{
  502. color: #ffffff;
  503. margin-left: 1em;
  504. }
  505. }
  506. .scanButton{
  507. margin: 0.8em 0 0.5em;
  508. padding: 0.5em;
  509. background: #066cff;
  510. color: #fff;
  511. font-size: 1.5em;
  512. border-radius: 5em;
  513. justify-content: center;
  514. &:active{
  515. opacity: 0.8;
  516. }
  517. }
  518. .quickButton{
  519. margin: 0 0 0.5em 0;
  520. padding: 0.5em;
  521. background: #fff;
  522. color: #333;
  523. font-size: 1.5em;
  524. border-radius: 5em;
  525. justify-content: center;
  526. border:0.1rpx solid #eee;
  527. box-shadow: 1rpx 2rpx 5rpx #f8f8f8;
  528. &:active{
  529. opacity: 0.8;
  530. }
  531. }
  532. .ml10{
  533. margin-left: 0.4em;
  534. }
  535. }
  536. .bg-blue{
  537. position: relative;
  538. > view{
  539. z-index: 100;
  540. position: relative;
  541. }
  542. &::after{
  543. /* 这个伪类的作用就是一个圆弧的背景色 */
  544. width: 130%;
  545. height: 100%;
  546. position: absolute;
  547. /*设置水平居中*/
  548. left: -15%;
  549. /* 之所以left:20%,是因为width:140%,若width:160%,那么left:30%才能水平居中 */
  550. top: -20%;
  551. /*层叠顺序,最底层显示*/
  552. content: '';
  553. border-radius: 0 0 50% 50%;
  554. /*分别对应 左上 右上 右下 左下 可以修改成其它颜色*/
  555. background: linear-gradient(to bottom, #066cff, #1d77ff);
  556. }
  557. .userCard{
  558. position:relative;
  559. left:0;
  560. bottom:-1rem;
  561. padding:0.8em;
  562. background: #fff;
  563. border-radius: 0.5em;
  564. box-shadow: 0.3em 0.3em 1em #c4e5ee;
  565. .userCard-info{
  566. flex-grow:1;
  567. > view{
  568. &:last-child{
  569. margin-left: 0.5em;
  570. line-height: 1.5em;
  571. .user-name{
  572. font-size: 1rem;
  573. }
  574. >view{
  575. padding: 0.2em;
  576. }
  577. }
  578. }
  579. .user-info{
  580. flex-grow:1;
  581. }
  582. }
  583. .user-rz{
  584. font-size: 0.8rem;
  585. color:#58aff5;
  586. }
  587. }
  588. }
  589. .list-box{
  590. padding: 0 1em;
  591. overflow: auto;
  592. .des{
  593. text-align: center;
  594. padding: 1em 0;
  595. color: #999;
  596. font-size: 0.8em;
  597. }
  598. }
  599. }
  600. </style>