index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view class="content">
  3. <view class="header-box">
  4. <view class="status_bar"></view>
  5. <view class="title"><text>管配件,就用</text>修配易码通</view>
  6. </view>
  7. <view class="body-box">
  8. <!-- 滚动区域 -->
  9. <view class="scroll-list">
  10. <scrollBox v-if="list.length" :list="list"></scrollBox>
  11. </view>
  12. <!-- 保证金 -->
  13. <view class="notices flex align_center" v-if="bondRecord" @click="toPayBondAmount">
  14. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有一笔保证金待支付 ¥{{bondRecord.bondAmount}}</view>
  15. <!-- <text>立即支付>></text> -->
  16. </view>
  17. <!-- 待取货提醒 -->
  18. <view class="notices flex align_center" v-if="!bondRecord&&orderTodo" @click="toOrder">
  19. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有待取货的货架订单哦!</view> <text>立即处理>></text>
  20. </view>
  21. <!-- 名片 -->
  22. <view class="userCard flex align_center justify_between" @click="toUser">
  23. <view class="userCard-info flex align_center justify_between">
  24. <view>
  25. <u-image v-if="!hasLogin" src="/static/def_personal_avatar.png" width="60" height="60"></u-image>
  26. <open-data v-else type="userAvatarUrl" class="user-photo"></open-data>
  27. </view>
  28. <view>
  29. <view v-if="!hasLogin" style="font-size: 40rpx;">
  30. 请点击登录
  31. </view>
  32. <view v-else>
  33. <view>{{userInfo.userNameCN}}</view>
  34. <view>{{userInfo.orgName}}</view>
  35. </view>
  36. </view>
  37. </view>
  38. <view>
  39. <u-icon name="arrow-right"></u-icon>
  40. </view>
  41. </view>
  42. <!-- 扫描按钮 -->
  43. <view class="scanButton flex align_center" @click="openCamera">
  44. <u-icon name="scan" size="40"></u-icon><text class="ml10">扫描VIN</text>
  45. </view>
  46. <!-- 扫描记录 -->
  47. <u-cell-group :border="false">
  48. <u-cell-item title="VIN查询历史" @click="toAllRecord" :title-style="{fontSize:'1.1em'}" :value="hasLogin?'查看全部':''">
  49. <u-icon slot="icon" size="38" v-if="hasLogin" color="#00aaff" style="margin-right: 0.3em;" name="order"></u-icon>
  50. </u-cell-item>
  51. </u-cell-group>
  52. </view>
  53. <!-- 扫描记录 -->
  54. <view class="list-box">
  55. <u-cell-group :border="false" v-if="hasLogin">
  56. <u-cell-item v-for="item in vinList" @click="toChoosePart(item)" :key="item.id" :title="item.vinCode" :title-style="{fontSize:'1em'}" :label="item.brandName +' '+item.modelName">
  57. <text slot="icon"></text>
  58. </u-cell-item>
  59. <view style="padding: 20upx;">
  60. <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>
  61. <u-loadmore v-if="status=='loading'" :status="status" />
  62. </view>
  63. </u-cell-group>
  64. <view class="des" v-if="vinList.length&&hasLogin">仅展示最近10条记录,点击“全部”查看更多</view>
  65. <view class="des" v-if="!hasLogin">请登录后查看历史记录</view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import {
  71. mapState,
  72. mapMutations,
  73. } from 'vuex'
  74. import scrollBox from '@/components/scrollBox.vue'
  75. import { shelfBondRecordWaitPayRecord, findStoreShelf, shelfGetTotalWaitQty } from '@/api/shelf.js'
  76. import { listLookUp, getLookUpDatas } from '@/api/data.js';
  77. import { scanVinLogQueryRoll, getScanVinLogList }from '@/api/car.js'
  78. export default {
  79. components: {
  80. scrollBox
  81. },
  82. data() {
  83. return {
  84. status: 'loading',
  85. noDataText: '暂无数据',
  86. bondRecord: null, // 保证金
  87. list:[],
  88. vinList: [],
  89. orderTodo: null,
  90. }
  91. },
  92. computed: {
  93. ...mapState(['hasLogin']),
  94. hasShelf(){
  95. return this.$store.state.vuex_storeShelf
  96. },
  97. userInfo(){
  98. return this.$store.state.vuex_userInfo
  99. }
  100. },
  101. onReady() {
  102. // 检测是否登录
  103. this.$store.dispatch('checkLogin',()=>{
  104. this.pageInit()
  105. })
  106. this.getScrollLog()
  107. },
  108. onLoad() {
  109. // 获取数据字典
  110. this.getListLookUp();
  111. // 获取支付,收款方式
  112. this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
  113. // 刷新首页数据
  114. uni.$on("refashHome",()=>{
  115. this.pageInit()
  116. })
  117. },
  118. onUnload() {
  119. uni.$off('refashHome')
  120. },
  121. // 下拉刷新
  122. onPullDownRefresh(){
  123. this.pageInit()
  124. setTimeout(function () {
  125. uni.stopPullDownRefresh();
  126. }, 1000);
  127. },
  128. methods: {
  129. pageInit(){
  130. if(this.hasLogin){
  131. // 查询是否有数字货架
  132. this.getStoreShelf()
  133. // 获取扫描记录
  134. this.getVinLog()
  135. }
  136. },
  137. // 获取数据字典
  138. getListLookUp() {
  139. const _this = this;
  140. listLookUp({ pageNo: 1, pageSize: 1000 }).then(res => {
  141. if (res.status == 200) {
  142. _this.$store.state.vuex_allLookUp = res.data;
  143. }
  144. });
  145. },
  146. // 或某一项字典列表,参数code
  147. getLookUpList(code, vuexKey) {
  148. getLookUpDatas({ type: code }).then(res => {
  149. if (res.status == 200) {
  150. this.$store.state[vuexKey] = res.data || [];
  151. }
  152. });
  153. },
  154. // 待取货数量合计
  155. shelfGetTotalWaitQty(){
  156. shelfGetTotalWaitQty({billState:'WAIT'}).then(res => {
  157. if(res.status == 200){
  158. this.orderTodo = res.data
  159. }
  160. })
  161. },
  162. // 货架订单列表
  163. toOrder(){
  164. if(this.hasShelf){
  165. uni.navigateTo({
  166. url: "/pages/digitalShelf/orderList"
  167. })
  168. }else{
  169. uni.showToast({
  170. icon:'none',
  171. title: '门店没有关联数字货架,无法使用此功能!'
  172. })
  173. }
  174. },
  175. getScrollLog(){
  176. scanVinLogQueryRoll({pageNo:1,pageSize:1000}).then(res => {
  177. this.list = res.data.list || []
  178. })
  179. },
  180. getVinLog(){
  181. this.vinList = []
  182. this.status = "loading"
  183. getScanVinLogList({pageNo:1,pageSize:10}).then(res => {
  184. this.vinList = res.data.list || []
  185. this.vinList = this.vinList.filter(item => item.vinCode)
  186. this.status = 'nomore'
  187. })
  188. },
  189. // 查询是否支持数字货架
  190. getStoreShelf(){
  191. findStoreShelf().then(res => {
  192. console.log(res)
  193. this.$store.state.vuex_storeShelf = res.data;
  194. if(res.data){
  195. // 保证金查询
  196. this.getShelfBWPayRecord()
  197. // 获取订单信息
  198. this.shelfGetTotalWaitQty()
  199. }
  200. })
  201. },
  202. // 获取保证金金额
  203. getShelfBWPayRecord(){
  204. const data = this.$store.state.vuex_storeShelf
  205. shelfBondRecordWaitPayRecord({shelfSn: data.shelfSn, storeSn: data.storeSn}).then(res => {
  206. console.log(res,'获取保证金金额')
  207. this.bondRecord = res.data
  208. })
  209. },
  210. // 保证金支付
  211. toPayBondAmount(){
  212. },
  213. // 去扫描
  214. openCamera(){
  215. uni.navigateTo({
  216. url: this.hasLogin ? "/pages/scan-frame/scan-frame" : '/pages/login/login'
  217. })
  218. },
  219. // 查看扫描记录
  220. toAllRecord(){
  221. uni.navigateTo({
  222. url: this.hasLogin ? "/pages/vinRecord/vinRecord" : '/pages/login/login'
  223. })
  224. },
  225. toUser(){
  226. uni.navigateTo({
  227. url: this.hasLogin ? '/pages/personData/personData' : '/pages/login/login'
  228. })
  229. },
  230. toChoosePart(item){
  231. if(this.hasShelf){
  232. item.text = item.modelInfo
  233. uni.navigateTo({
  234. url: "/pages/digitalShelf/choosePart?vinNumber="+item.vinCode+"&carList="+encodeURIComponent(JSON.stringify(item))
  235. })
  236. }else{
  237. uni.showToast({
  238. icon:'none',
  239. title: '门店没有关联数字货架,无法使用此功能!'
  240. })
  241. }
  242. }
  243. }
  244. }
  245. </script>
  246. <style lang="less">
  247. .content {
  248. margin: 0;
  249. padding: 0;
  250. height: 100vh;
  251. display: flex;
  252. flex-direction: column;
  253. background-image: linear-gradient(#86defa 0%,#cdeff9 25%,#ffffff 40%);
  254. .header-box{
  255. padding: 0.3em 1em;
  256. .status_bar {
  257. height: var(--status-bar-height);
  258. width: 100%;
  259. }
  260. .title{
  261. padding-top: 0.4em;
  262. font-size: 1.5em;
  263. color: #000;
  264. text{
  265. color: #0077fd;
  266. }
  267. }
  268. }
  269. .body-box{
  270. padding: 0.5em 1em;
  271. .notices{
  272. padding: 0.5em 0 0;
  273. view{
  274. color: #f2a557;
  275. }
  276. text{
  277. color: #0077fd;
  278. margin-left: 1em;
  279. }
  280. }
  281. .userCard{
  282. margin-top: 0.8em;
  283. padding:0.8em;
  284. background: #fff;
  285. border-radius: 1em;
  286. box-shadow: 0.2em 0.3em 0.8em #cdeff9;
  287. .userCard-info{
  288. > view{
  289. &:last-child{
  290. margin-left: 0.5em;
  291. >view{
  292. padding: 0.2em;
  293. }
  294. }
  295. }
  296. }
  297. .user-photo{
  298. display: block;
  299. width: 120rpx;
  300. height: 120rpx;
  301. border-radius: 50%;
  302. overflow: hidden;
  303. }
  304. }
  305. .scanButton{
  306. margin: 0.6em 0;
  307. padding: 0.5em;
  308. background: #1283d4;
  309. color: #fff;
  310. font-size: 1.5em;
  311. border-radius: 5em;
  312. justify-content: center;
  313. &:active{
  314. opacity: 0.8;
  315. }
  316. }
  317. .ml10{
  318. margin-left: 0.2em;
  319. }
  320. }
  321. .list-box{
  322. flex-grow: 1;
  323. padding: 0 1em;
  324. overflow: auto;
  325. .des{
  326. text-align: center;
  327. padding: 1em 0;
  328. color: #999;
  329. font-size: 0.8em;
  330. }
  331. }
  332. }
  333. </style>