index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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. const _this = this
  362. // 扫描
  363. if(index == 0){
  364. uni.scanCode({
  365. success: function (res) {
  366. console.log(res);
  367. const params = {
  368. codeType: res.scanType == 'QR_CODE' ? 0 : 1,
  369. }
  370. // 二维码
  371. if(res.scanType == 'QR_CODE'){
  372. const ret = res.result.split("&")
  373. params.productSn = ret[2] // 产品编码sn
  374. }else{
  375. params.qrCode = res.result
  376. }
  377. uni.showLoading({
  378. title: "正在查询产品..."
  379. })
  380. // 确认取货
  381. getProductfindByScanCode(params).then(res => {
  382. if(res.status == 200 && res.data){
  383. if(res.data.currentInven){
  384. const params = Object.assign({shelfSn: shelfSn, billSource: res.scanType == 'QR_CODE' ? 'qr_code': 'bar_code'},res.data)
  385. _this.$store.state.vuex_tempData = params
  386. uni.navigateTo({
  387. url: '/pages/queryByCode/confirmQh'
  388. })
  389. }else{
  390. uni.showModal({
  391. title: '提示',
  392. content: '产品库存为0,无法取货!',
  393. confirmText: '好的',
  394. showCancel: false
  395. })
  396. }
  397. }else{
  398. uni.showModal({
  399. title: '提示',
  400. content: '产品不属于此货架,请重新扫描!',
  401. confirmText: '好的',
  402. showCancel: false
  403. })
  404. }
  405. uni.hideLoading()
  406. })
  407. }
  408. });
  409. }else{
  410. // 按编码搜索
  411. uni.navigateTo({
  412. url: '/pages/queryByCode/queryByCode'
  413. })
  414. }
  415. },
  416. // 去扫描
  417. openCamera(){
  418. if(this.hasLogin){
  419. if(this.userInfo.sysUserFlag == '0'){
  420. if(this.vuex_vinScanNums < this.scanMaxNums){
  421. uni.navigateTo({
  422. url: "/pages/scan-frame/scan-frame"
  423. })
  424. }else{
  425. uni.showModal({
  426. title: '提示',
  427. content: '个人用户扫描VIN仅限10次,您的次数已用完!',
  428. confirmText: '好的',
  429. showCancel: false,
  430. success(res) {}
  431. })
  432. }
  433. }else{
  434. uni.navigateTo({
  435. url: "/pages/scan-frame/scan-frame"
  436. })
  437. }
  438. }else{
  439. uni.navigateTo({
  440. url: '/pages/login/login'
  441. })
  442. }
  443. },
  444. // 查看扫描记录
  445. toAllRecord(){
  446. uni.navigateTo({
  447. url: this.hasLogin ? "/pages/vinRecord/vinRecord" : '/pages/login/login'
  448. })
  449. },
  450. toUser(){
  451. if(this.hasLogin){
  452. // 用户详细信息 或 门店认证
  453. uni.navigateTo({
  454. url: this.userInfo.sysUserFlag == '1' ? '/pages/personData/personData' : '/pages/storeManage/storeAuth'
  455. })
  456. }else{
  457. uni.navigateTo({
  458. url: '/pages/login/login'
  459. })
  460. }
  461. },
  462. toChoosePart(item){
  463. item.text = item.modelInfo
  464. uni.navigateTo({
  465. url: "/pages/digitalShelf/choosePart?vinNumber="+item.vinCode+"&carList="+encodeURIComponent(JSON.stringify(item))
  466. })
  467. }
  468. }
  469. }
  470. </script>
  471. <style lang="less">
  472. .content {
  473. margin: 0;
  474. padding: 0;
  475. height: 100vh;
  476. display: flex;
  477. flex-direction: column;
  478. background-image: linear-gradient(#86defa 0%,#cdeff9 25%,#ffffff 40%);
  479. .header-box{
  480. z-index: 5;
  481. padding: 0em 1em;
  482. background: #066cff;
  483. .title{
  484. padding: 0;
  485. }
  486. }
  487. .cbody{
  488. flex-grow: 1;
  489. overflow-y: auto;
  490. overflow-x: hidden;
  491. }
  492. .body-box{
  493. padding: 0em 1em 0.8em;
  494. z-index: 4;
  495. .notices{
  496. padding: 0.5em 0 0;
  497. font-size: 0.9em;
  498. margin-top: 0.5rem;
  499. view{
  500. color: #ffaf46;
  501. max-width: 80%;
  502. }
  503. .text{
  504. color: #ffffff;
  505. margin-left: 1em;
  506. }
  507. }
  508. .scanButton{
  509. margin: 0.8em 0 0.5em;
  510. padding: 0.5em;
  511. background: #066cff;
  512. color: #fff;
  513. font-size: 1.5em;
  514. border-radius: 5em;
  515. justify-content: center;
  516. &:active{
  517. opacity: 0.8;
  518. }
  519. }
  520. .quickButton{
  521. margin: 0 0 0.5em 0;
  522. padding: 0.5em;
  523. background: #fff;
  524. color: #333;
  525. font-size: 1.5em;
  526. border-radius: 5em;
  527. justify-content: center;
  528. border:0.1rpx solid #eee;
  529. box-shadow: 1rpx 2rpx 5rpx #f8f8f8;
  530. &:active{
  531. opacity: 0.8;
  532. }
  533. }
  534. .ml10{
  535. margin-left: 0.4em;
  536. }
  537. }
  538. .bg-blue{
  539. position: relative;
  540. > view{
  541. z-index: 100;
  542. position: relative;
  543. }
  544. &::after{
  545. /* 这个伪类的作用就是一个圆弧的背景色 */
  546. width: 130%;
  547. height: 100%;
  548. position: absolute;
  549. /*设置水平居中*/
  550. left: -15%;
  551. /* 之所以left:20%,是因为width:140%,若width:160%,那么left:30%才能水平居中 */
  552. top: -20%;
  553. /*层叠顺序,最底层显示*/
  554. content: '';
  555. border-radius: 0 0 50% 50%;
  556. /*分别对应 左上 右上 右下 左下 可以修改成其它颜色*/
  557. background: linear-gradient(to bottom, #066cff, #1d77ff);
  558. }
  559. .userCard{
  560. position:relative;
  561. left:0;
  562. bottom:-1rem;
  563. padding:0.8em;
  564. background: #fff;
  565. border-radius: 0.5em;
  566. box-shadow: 0.3em 0.3em 1em #c4e5ee;
  567. .userCard-info{
  568. flex-grow:1;
  569. > view{
  570. &:last-child{
  571. margin-left: 0.5em;
  572. line-height: 1.5em;
  573. .user-name{
  574. font-size: 1rem;
  575. }
  576. >view{
  577. padding: 0.2em;
  578. }
  579. }
  580. }
  581. .user-info{
  582. flex-grow:1;
  583. }
  584. }
  585. .user-rz{
  586. font-size: 0.8rem;
  587. color:#58aff5;
  588. }
  589. }
  590. }
  591. .list-box{
  592. padding: 0 1em;
  593. overflow: auto;
  594. .des{
  595. text-align: center;
  596. padding: 1em 0;
  597. color: #999;
  598. font-size: 0.8em;
  599. }
  600. }
  601. }
  602. </style>