index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  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="showAction = true">
  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 } 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. pageInit(){
  204. if(this.hasLogin){
  205. // 获取扫描记录
  206. this.getVinLog()
  207. // 非游客
  208. if(this.userInfo.sysUserFlag == '1'){
  209. // 查询是否有数字货架
  210. this.getStoreShelf()
  211. }else{
  212. // 获取扫描次数
  213. this.$store.dispatch("getScanNums")
  214. // 获取最大扫描次数
  215. this.getMaxQty()
  216. // 查询门店认证信息
  217. this.findLastApply()
  218. }
  219. }else{
  220. uni.removeStorageSync('token')
  221. }
  222. },
  223. // 获取数据字典
  224. getListLookUp() {
  225. const _this = this;
  226. listLookUp({ pageNo: 1, pageSize: 1000 }).then(res => {
  227. if (res.status == 200) {
  228. _this.$store.state.vuex_allLookUp = res.data;
  229. }
  230. });
  231. },
  232. // 或某一项字典列表,参数code
  233. getLookUpList(code, vuexKey) {
  234. getLookUpDatas({ type: code }).then(res => {
  235. if (res.status == 200) {
  236. this.$store.state[vuexKey] = res.data || [];
  237. }
  238. });
  239. },
  240. // 获取最大扫描数
  241. getMaxQty(){
  242. getScanGetMaxQty().then(res => {
  243. this.scanMaxNums = res.data || 10
  244. this.$store.state.vuex_scanMaxNums = this.scanMaxNums
  245. })
  246. },
  247. // 获取最新申请门店
  248. findLastApply(){
  249. const mobile = this.userInfo.mobile
  250. this.$store.dispatch('getSotreAuth',mobile)
  251. },
  252. // 知道审核不通过
  253. toKnow(){
  254. uni.showLoading({
  255. title: "正在提交"
  256. })
  257. xprhStoreApplyRead({sn:this.storeApply.applySn}).then(res => {
  258. if(res.status == 200){
  259. this.findLastApply()
  260. }
  261. uni.hideLoading()
  262. })
  263. },
  264. // 待取货数量合计
  265. shelfGetTotalWaitQty(){
  266. shelfGetTotalWaitQty({billState:'WAIT'}).then(res => {
  267. if(res.status == 200){
  268. this.orderTodo = res.data;
  269. }
  270. })
  271. },
  272. // 货架订单列表
  273. toOrder(){
  274. if(this.hasShelf){
  275. uni.navigateTo({
  276. url: "/pages/digitalShelf/orderList"
  277. })
  278. }else{
  279. uni.showToast({
  280. icon:'none',
  281. title: '门店没有关联数字货架,无法使用此功能!'
  282. })
  283. }
  284. },
  285. // 获取上方滚动扫描记录
  286. getScrollLog(){
  287. scanVinLogQueryRoll({pageNo:1,pageSize:1000}).then(res => {
  288. console.log(res)
  289. this.list = res.data.list || []
  290. })
  291. },
  292. // 获取当前门店扫描记录
  293. getVinLog(){
  294. this.vinList = []
  295. this.status = "loading"
  296. // VISITOR:游客,EMPLOYEE:雇员
  297. getScanVinLogList({ pageNo:1, pageSize:5, identifyType: this.userInfo.identifyType }).then(res => {
  298. this.vinList = res.data&&res.data.list || []
  299. this.vinList = this.vinList.filter(item => item.vinCode)
  300. this.status = 'nomore'
  301. })
  302. },
  303. // 查询是否支持数字货架
  304. getStoreShelf(){
  305. findStoreShelf().then(res => {
  306. console.log(res)
  307. this.$store.state.vuex_storeShelf = res.data;
  308. if(res.data){
  309. // 保证金查询
  310. this.getShelfBWPayRecord()
  311. // 获取订单信息
  312. this.shelfGetTotalWaitQty()
  313. }
  314. })
  315. },
  316. // 获取保证金金额
  317. getShelfBWPayRecord(){
  318. const data = this.$store.state.vuex_storeShelf
  319. shelfBondRecordWaitPayRecord({shelfSn: data.shelfSn, storeSn: data.storeSn}).then(res => {
  320. console.log(res,'获取保证金金额')
  321. this.bondRecord = res.data
  322. })
  323. },
  324. // 保证金支付
  325. toPayBondAmount(){},
  326. // 选择取货方式
  327. clickAction(index){
  328. const shelfSn = this.hasShelf.shelfSn
  329. // 扫描
  330. if(index == 0){
  331. uni.scanCode({
  332. success: function (res) {
  333. console.log(res);
  334. const params = {
  335. codeType: res.scanType == 'QR_CODE' ? 0 : 1,
  336. }
  337. // 二维码
  338. if(res.scanType == 'QR_CODE'){
  339. const ret = res.result.split("&")
  340. params.productSn = ret[1] // 产品编码sn
  341. }else{
  342. params.qrCode = res.result
  343. }
  344. uni.showLoading({
  345. title: "正在查询产品..."
  346. })
  347. // 确认取货
  348. getProductfindByScanCode(params).then(res => {
  349. if(res.status == 200 && res.data){
  350. if(res.data.currentInven){
  351. const params = Object.assign({shelfSn: shelfSn, billSource: res.scanType == 'QR_CODE' ? 'qr_code': 'bar_code'},res.data)
  352. uni.navigateTo({
  353. url: '/pages/queryByCode/confirmQh?data='+ encodeURIComponent(JSON.stringify(res.data))
  354. })
  355. }else{
  356. uni.showModal({
  357. title: '提示',
  358. content: '产品库存为0,无法取货!',
  359. confirmText: '好的',
  360. showCancel: false
  361. })
  362. }
  363. }else{
  364. uni.showModal({
  365. title: '提示',
  366. content: '产品不属于此货架,请重新扫描!',
  367. confirmText: '好的',
  368. showCancel: false
  369. })
  370. }
  371. uni.hideLoading()
  372. })
  373. }
  374. });
  375. }else{
  376. // 按编码搜索
  377. uni.navigateTo({
  378. url: '/pages/queryByCode/queryByCode'
  379. })
  380. }
  381. },
  382. // 去扫描
  383. openCamera(){
  384. if(this.hasLogin){
  385. if(this.userInfo.sysUserFlag == '0'){
  386. if(this.vuex_vinScanNums < this.scanMaxNums){
  387. uni.navigateTo({
  388. url: "/pages/scan-frame/scan-frame"
  389. })
  390. }else{
  391. uni.showModal({
  392. title: '提示',
  393. content: '个人用户扫描VIN仅限10次,您的次数已用完!',
  394. confirmText: '好的',
  395. showCancel: false,
  396. success(res) {}
  397. })
  398. }
  399. }else{
  400. uni.navigateTo({
  401. url: "/pages/scan-frame/scan-frame"
  402. })
  403. }
  404. }else{
  405. uni.navigateTo({
  406. url: '/pages/login/login'
  407. })
  408. }
  409. },
  410. // 查看扫描记录
  411. toAllRecord(){
  412. uni.navigateTo({
  413. url: this.hasLogin ? "/pages/vinRecord/vinRecord" : '/pages/login/login'
  414. })
  415. },
  416. toUser(){
  417. if(this.hasLogin){
  418. // 用户详细信息 或 门店认证
  419. uni.navigateTo({
  420. url: this.userInfo.sysUserFlag == '1' ? '/pages/personData/personData' : '/pages/storeManage/storeAuth'
  421. })
  422. }else{
  423. uni.navigateTo({
  424. url: '/pages/login/login'
  425. })
  426. }
  427. },
  428. toChoosePart(item){
  429. item.text = item.modelInfo
  430. uni.navigateTo({
  431. url: "/pages/digitalShelf/choosePart?vinNumber="+item.vinCode+"&carList="+encodeURIComponent(JSON.stringify(item))
  432. })
  433. }
  434. }
  435. }
  436. </script>
  437. <style lang="less">
  438. .content {
  439. margin: 0;
  440. padding: 0;
  441. height: 100vh;
  442. display: flex;
  443. flex-direction: column;
  444. background-image: linear-gradient(#86defa 0%,#cdeff9 25%,#ffffff 40%);
  445. .header-box{
  446. z-index: 5;
  447. padding: 0em 1em;
  448. background: #066cff;
  449. .title{
  450. padding: 0;
  451. }
  452. }
  453. .cbody{
  454. flex-grow: 1;
  455. overflow-y: auto;
  456. overflow-x: hidden;
  457. }
  458. .body-box{
  459. padding: 0em 1em 0.8em;
  460. z-index: 4;
  461. .notices{
  462. padding: 0.5em 0 0;
  463. font-size: 0.9em;
  464. margin-top: 0.5rem;
  465. view{
  466. color: #ffaf46;
  467. max-width: 80%;
  468. }
  469. .text{
  470. color: #ffffff;
  471. margin-left: 1em;
  472. }
  473. }
  474. .scanButton{
  475. margin: 0.8em 0 0.5em;
  476. padding: 0.5em;
  477. background: #066cff;
  478. color: #fff;
  479. font-size: 1.5em;
  480. border-radius: 5em;
  481. justify-content: center;
  482. &:active{
  483. opacity: 0.8;
  484. }
  485. }
  486. .quickButton{
  487. margin: 0 0 0.5em 0;
  488. padding: 0.5em;
  489. background: #fff;
  490. color: #333;
  491. font-size: 1.5em;
  492. border-radius: 5em;
  493. justify-content: center;
  494. border:0.1rpx solid #eee;
  495. box-shadow: 1rpx 2rpx 5rpx #f8f8f8;
  496. &:active{
  497. opacity: 0.8;
  498. }
  499. }
  500. .ml10{
  501. margin-left: 0.4em;
  502. }
  503. }
  504. .bg-blue{
  505. position: relative;
  506. > view{
  507. z-index: 100;
  508. position: relative;
  509. }
  510. &::after{
  511. /* 这个伪类的作用就是一个圆弧的背景色 */
  512. width: 130%;
  513. height: 100%;
  514. position: absolute;
  515. /*设置水平居中*/
  516. left: -15%;
  517. /* 之所以left:20%,是因为width:140%,若width:160%,那么left:30%才能水平居中 */
  518. top: -20%;
  519. /*层叠顺序,最底层显示*/
  520. content: '';
  521. border-radius: 0 0 50% 50%;
  522. /*分别对应 左上 右上 右下 左下 可以修改成其它颜色*/
  523. background: linear-gradient(to bottom, #066cff, #1d77ff);
  524. }
  525. .userCard{
  526. position:relative;
  527. left:0;
  528. bottom:-1rem;
  529. padding:0.8em;
  530. background: #fff;
  531. border-radius: 0.5em;
  532. box-shadow: 0.3em 0.3em 1em #c4e5ee;
  533. .userCard-info{
  534. flex-grow:1;
  535. > view{
  536. &:last-child{
  537. margin-left: 0.5em;
  538. line-height: 1.5em;
  539. .user-name{
  540. font-size: 1rem;
  541. }
  542. >view{
  543. padding: 0.2em;
  544. }
  545. }
  546. }
  547. .user-info{
  548. flex-grow:1;
  549. }
  550. }
  551. .user-rz{
  552. font-size: 0.8rem;
  553. color:#58aff5;
  554. }
  555. }
  556. }
  557. .list-box{
  558. padding: 0 1em;
  559. overflow: auto;
  560. .des{
  561. text-align: center;
  562. padding: 1em 0;
  563. color: #999;
  564. font-size: 0.8em;
  565. }
  566. }
  567. }
  568. </style>