index.vue 17 KB

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