index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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> <text>立即支付>></text>
  15. </view>
  16. <!-- 名片 -->
  17. <view class="userCard flex align_center justify_between" @click="toUser">
  18. <view class="userCard-info flex align_center justify_between">
  19. <view>
  20. <u-image v-if="!hasLogin" src="/static/def_personal_avatar.png" width="60" height="60"></u-image>
  21. <open-data v-else type="userAvatarUrl" class="user-photo"></open-data>
  22. </view>
  23. <view>
  24. <view v-if="!hasLogin" style="font-size: 40rpx;">
  25. 请点击登录/注册
  26. </view>
  27. <view v-else>
  28. <view>{{userInfo.userNameCN}}</view>
  29. <view>{{userInfo.orgName}}</view>
  30. </view>
  31. </view>
  32. </view>
  33. <view>
  34. <u-icon name="arrow-right"></u-icon>
  35. </view>
  36. </view>
  37. <!-- 扫描按钮 -->
  38. <view class="scanButton flex align_center" @click="openCamera">
  39. <u-icon name="scan" size="40"></u-icon><text class="ml10">扫描VIN</text>
  40. </view>
  41. <!-- 扫描记录 -->
  42. <u-cell-group :border="false">
  43. <u-cell-item title="扫描记录" @click="toAllRecord" :title-style="{fontSize:'1.1em'}" :value="hasLogin?'查看全部':''">
  44. <u-icon slot="icon" size="38" v-if="hasLogin" color="#00aaff" style="margin-right: 0.3em;" name="order"></u-icon>
  45. </u-cell-item>
  46. </u-cell-group>
  47. </view>
  48. <!-- 扫描记录 -->
  49. <view class="list-box">
  50. <u-cell-group :border="false" v-if="hasLogin">
  51. <u-cell-item v-for="item in vinList" :key="item.id" :title="item.vinCode" :title-style="{fontSize:'1em'}" :value="item.brandName +' '+item.modelName">
  52. <text slot="icon"></text>
  53. </u-cell-item>
  54. <view style="padding: 20upx;">
  55. <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>
  56. <u-loadmore v-if="status=='loading'" :status="status" />
  57. </view>
  58. </u-cell-group>
  59. <view class="des" v-if="vinList.length">仅展示最近10条记录,点击“全部”查看更多</view>
  60. <view class="des" v-if="!hasLogin">请登录后,查看扫描记录</view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. mapState,
  67. mapMutations,
  68. } from 'vuex'
  69. import scrollBox from '@/components/scrollBox.vue'
  70. import { shelfBondRecordWaitPayRecord, findStoreShelf } from '@/api/shelf.js'
  71. import { listLookUp, getLookUpDatas } from '@/api/data.js';
  72. import { scanVinLogQueryRoll, getScanVinLogList }from '@/api/car.js'
  73. export default {
  74. components: {
  75. scrollBox
  76. },
  77. data() {
  78. return {
  79. status: 'loading',
  80. noDataText: '暂无数据',
  81. bondRecord: null, // 保证金
  82. list:[],
  83. vinList: []
  84. }
  85. },
  86. computed: {
  87. ...mapState(['hasLogin']),
  88. hasShelf(){
  89. return this.$store.state.vuex_storeShelf
  90. },
  91. userInfo(){
  92. return this.$store.state.vuex_userInfo
  93. }
  94. },
  95. onLoad() {
  96. // 检测是否登录
  97. this.$store.dispatch('checkLogin')
  98. // 获取数据字典
  99. this.getListLookUp();
  100. // 获取支付,收款方式
  101. this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
  102. },
  103. onShow() {
  104. if(this.hasLogin){
  105. // 查询是否有数字货架
  106. this.getStoreShelf()
  107. // 获取扫描记录
  108. this.getVinLog()
  109. }
  110. this.getScrollLog()
  111. },
  112. methods: {
  113. // 获取数据字典
  114. getListLookUp() {
  115. const _this = this;
  116. listLookUp({ pageNo: 1, pageSize: 1000 }).then(res => {
  117. if (res.status == 200) {
  118. _this.$store.state.vuex_allLookUp = res.data;
  119. }
  120. });
  121. },
  122. // 或某一项字典列表,参数code
  123. getLookUpList(code, vuexKey) {
  124. getLookUpDatas({ type: code }).then(res => {
  125. if (res.status == 200) {
  126. this.$store.state[vuexKey] = res.data || [];
  127. }
  128. });
  129. },
  130. getScrollLog(){
  131. scanVinLogQueryRoll({pageNo:1,pageSize:1000}).then(res => {
  132. this.list = res.data.list || []
  133. })
  134. },
  135. getVinLog(){
  136. this.status = "loading"
  137. getScanVinLogList({pageNo:1,pageSize:10}).then(res => {
  138. this.vinList = res.data.list || []
  139. this.vinList = this.vinList.filter(item => item.vinCode)
  140. this.status = 'nomore'
  141. })
  142. },
  143. // 查询是否支持数字货架
  144. getStoreShelf(){
  145. findStoreShelf().then(res => {
  146. console.log(res)
  147. this.$store.state.vuex_storeShelf = res.data;
  148. if(res.data){
  149. // 保证金查询
  150. this.getShelfBWPayRecord()
  151. }
  152. })
  153. },
  154. // 获取保证金金额
  155. getShelfBWPayRecord(){
  156. const data = this.$store.state.vuex_storeShelf
  157. shelfBondRecordWaitPayRecord({shelfSn: data.shelfSn, storeSn: data.storeSn}).then(res => {
  158. console.log(res,'获取保证金金额')
  159. this.bondRecord = res.data
  160. })
  161. },
  162. // 保证金支付
  163. toPayBondAmount(){
  164. },
  165. // 去扫描
  166. openCamera(){
  167. uni.navigateTo({
  168. url: this.hasLogin ? "/pages/scan-frame/scan-frame" : '/pages/login/login'
  169. })
  170. },
  171. // 查看扫描记录
  172. toAllRecord(){
  173. uni.navigateTo({
  174. url: this.hasLogin ? "/pages/vinRecord/vinRecord" : '/pages/login/login'
  175. })
  176. },
  177. toUser(){
  178. uni.navigateTo({
  179. url: this.hasLogin ? '/pages/personData/personData' : '/pages/login/login'
  180. })
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="less">
  186. .content {
  187. margin: 0;
  188. padding: 0;
  189. height: 100vh;
  190. display: flex;
  191. flex-direction: column;
  192. background-image: linear-gradient(#86defa 0%,#cdeff9 25%,#ffffff 40%);
  193. .header-box{
  194. padding: 0.3em 1em;
  195. .status_bar {
  196. height: var(--status-bar-height);
  197. width: 100%;
  198. }
  199. .title{
  200. padding-top: 0.4em;
  201. font-size: 1.5em;
  202. color: #000;
  203. text{
  204. color: #0077fd;
  205. }
  206. }
  207. }
  208. .body-box{
  209. padding: 0.5em 1em;
  210. .notices{
  211. padding: 0.5em 0 0;
  212. view{
  213. color: #f2a557;
  214. }
  215. text{
  216. color: #0077fd;
  217. margin-left: 1em;
  218. }
  219. }
  220. .userCard{
  221. margin-top: 0.8em;
  222. padding:0.8em;
  223. background: #fff;
  224. border-radius: 1em;
  225. box-shadow: 0.2em 0.3em 0.8em #cdeff9;
  226. .userCard-info{
  227. > view{
  228. &:last-child{
  229. margin-left: 0.5em;
  230. >view{
  231. padding: 0.2em;
  232. }
  233. }
  234. }
  235. }
  236. .user-photo{
  237. display: block;
  238. width: 120rpx;
  239. height: 120rpx;
  240. border-radius: 50%;
  241. overflow: hidden;
  242. }
  243. }
  244. .scanButton{
  245. margin: 0.6em 0;
  246. padding: 0.5em;
  247. background: #1283d4;
  248. color: #fff;
  249. font-size: 1.5em;
  250. border-radius: 5em;
  251. justify-content: center;
  252. &:active{
  253. opacity: 0.8;
  254. }
  255. }
  256. .ml10{
  257. margin-left: 0.2em;
  258. }
  259. }
  260. .list-box{
  261. flex-grow: 1;
  262. padding: 0 1em;
  263. overflow: auto;
  264. .des{
  265. text-align: center;
  266. padding: 1em 0;
  267. color: #999;
  268. font-size: 0.8em;
  269. }
  270. }
  271. }
  272. </style>