scan-info.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <view class="main">
  3. <view class="ExchangeStation">
  4. <view class="ExchangeTitle">
  5. <image src="../../static/p3.png"></image><span>换电站信息</span>
  6. </view>
  7. <view class="Exchange-context">
  8. <view class="list"><span>换电站编号</span><span>{{swapInfoDTO.stationCode}}</span></view>
  9. <view class="list"><span>换电站名称</span><span>{{swapInfoDTO.stationName}}</span></view>
  10. <view class="list"><span>可用电池数</span><span>{{swapInfoDTO.availablePoses.length}}</span></view>
  11. </view>
  12. </view>
  13. <view class="ExchangeStation">
  14. <view class="ExchangeTitle">
  15. <image src="../../static/p1.png"></image><span>车辆信息</span>
  16. </view>
  17. <view class="Exchange-context">
  18. <view class="list"><span>车牌号码</span><span>{{swapInfoDTO.plate || '—'}}</span></view>
  19. </view>
  20. </view>
  21. <view class="Exchange-tips">
  22. <view class="tips-top">
  23. <image src="../../static/p6.png"></image><span>提醒</span>
  24. </view>
  25. <view class="tips-bottom">
  26. <view>1:请停留在正确的换电位上</view>
  27. <view>2:请确认车辆已熄火</view>
  28. <view>3:换电遇到问题,请联系现场工作人员</view>
  29. </view>
  30. </view>
  31. <button v-if="!isShowNovice" type="primary" @click.once="swapSubmit" :disabled="BtnText!='确认换电'"
  32. class="submit">{{BtnText}}</button>
  33. <uni-popup ref="reScan" :mask-click="false">
  34. <view class="rescan">
  35. <image src="../../static/p7.png"></image>
  36. <view>{{getExchangeMsg}}</view>
  37. <view>请重新扫码换电!</view>
  38. <view><button type="primary" class="sanBtn" @click="reScan">重新扫码</button></view>
  39. </view>
  40. </uni-popup>
  41. <!-- 换电指南 -->
  42. <view class="novice-guidance" v-if="isShowNovice">
  43. <view class="shdow">
  44. <view class="novice-guidance-btn" @click="isShowNovice = false">我知道了</view>
  45. <image
  46. src="https://rl-zk-image.oss-cn-hangzhou.aliyuncs.com/image/2023-07/20230710102645wx_new_advice.png"
  47. class="novice-guidance-img"></image>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. name: "scan-info",
  55. props: ['swapInfoDTO', 'sendSwapState', 'beginSwapresult', 'getExchangeMsg'],
  56. data() {
  57. return {
  58. percent: 0,
  59. currentAngle: null,
  60. angleTimer: null,
  61. stationCode: null,
  62. isShowNovice: false
  63. }
  64. },
  65. beforeCreate() {
  66. if (!uni.getStorageSync("token")) {
  67. uni.reLaunch({
  68. url: '/pages/public/login?item=scan'
  69. })
  70. }
  71. },
  72. computed: {
  73. BtnText() {
  74. if (this.swapInfoDTO.stationConn == 0) {
  75. return '站点未连接'
  76. }
  77. if (!this.swapInfoDTO.plate) {
  78. return '无车辆信息'
  79. }
  80. if (this.swapInfoDTO.availablePoses.length <= 0) {
  81. return '无可用电池'
  82. }
  83. if (this.swapInfoDTO.stationConn != 0 && this.swapInfoDTO.plate && this.swapInfoDTO.availablePoses.length >
  84. 0) {
  85. return '确认换电'
  86. }
  87. }
  88. },
  89. mounted() {
  90. this.getUcenterData()
  91. },
  92. watch: {
  93. beginSwapresult(val) {
  94. if (val !== -1) {
  95. uni.hideLoading()
  96. if (val === 1) {
  97. this.$refs.reScan.open() //换电未启动重新扫码
  98. }
  99. }
  100. }
  101. },
  102. methods: {
  103. //获取换电次数
  104. getUcenterData() {
  105. this.$http.ucenterData().then(rs => {
  106. if (rs.code === 0) {
  107. this.isShowNovice = !rs.data.exchangeCnt
  108. } else {
  109. //this.$utils.msg(rs.msg);
  110. }
  111. }).catch(error => {
  112. //this.$utils.msg(error);
  113. });
  114. },
  115. //重新扫码
  116. reScan() {
  117. if (this.$storage.getJson("token")) {
  118. // let stationCode = 'ZL000003'
  119. // uni.redirectTo({
  120. // url: '/pages/powerchange/index?stationCode=' + stationCode
  121. // })
  122. let that = this
  123. uni.scanCode({
  124. success: function(res) {
  125. const url = res.result
  126. if (url.startsWith('https://zk.li-ai.com.cn/?stationCode=')) {
  127. const parts = url.split("=")
  128. if (parts.length === 2) {
  129. that.stationCode = parts[1]
  130. uni.redirectTo({
  131. url: '/pages/powerchange/index?stationCode=' + that.stationCode
  132. })
  133. } else {
  134. uni.redirectTo({
  135. url: '/pages/public/404?error=' + '站点编号错误!!'
  136. })
  137. }
  138. } else {
  139. uni.redirectTo({
  140. url: '/pages/public/404?error=' + '二维码链接错误!!'
  141. })
  142. }
  143. },
  144. });
  145. } else {
  146. uni.redirectTo({
  147. url: '/pages/public/login',
  148. });
  149. }
  150. },
  151. //发起换电请求
  152. swapSubmit() {
  153. let that = this
  154. uni.showLoading({
  155. title: '等待响应...',
  156. });
  157. if (uni.getStorageSync("token")) {
  158. let msg = {
  159. type: "startExchange",
  160. payLoad: {}
  161. }
  162. //触发发起换电事件
  163. this.$bus.$emit('sendMsg2', {
  164. data: JSON.stringify(msg)
  165. })
  166. } else {
  167. uni.reLaunch({
  168. url: '/pages/public/login?item=scan'
  169. })
  170. }
  171. },
  172. }
  173. }
  174. </script>
  175. <style lang="scss" scoped>
  176. .main {
  177. height: 100vh;
  178. }
  179. .shdow {
  180. width: 100vw;
  181. height: 100vh;
  182. position: fixed;
  183. background: rgba(0, 0, 0, 0.6);
  184. left: 0;
  185. bottom: 0;
  186. overflow: hidden;
  187. .novice-guidance-btn {
  188. width: 200rpx;
  189. height: 88rpx;
  190. border-radius: 55rpx;
  191. opacity: 1;
  192. border: 2rpx solid #FFFFFF;
  193. text-align: center;
  194. line-height: 88rpx;
  195. font-size: 32rpx;
  196. font-family: PingFang SC-Regular, PingFang SC;
  197. font-weight: 400;
  198. color: #FFFFFF;
  199. margin: auto;
  200. margin-top: 211rpx;
  201. }
  202. .novice-guidance-img {
  203. width: 694rpx;
  204. height: 703rpx;
  205. margin-left: 49rpx;
  206. margin-top: 120rpx;
  207. }
  208. }
  209. .rescan {
  210. width: 500rpx;
  211. height: 468rpx;
  212. border-radius: 15rpx;
  213. background-color: #fff;
  214. display: flex;
  215. flex-direction: column;
  216. align-items: center;
  217. image {
  218. width: 131rpx;
  219. height: 148rpx;
  220. margin-top: 54rpx;
  221. }
  222. view:nth-child(2) {
  223. font-size: 34rpx;
  224. font-weight: 600;
  225. color: #1D2129;
  226. margin-top: 10rpx;
  227. }
  228. view:nth-child(3) {
  229. font-size: 30rpx;
  230. font-weight: 400;
  231. color: #4E5969;
  232. margin-top: 16rpx;
  233. }
  234. .sanBtn {
  235. width: 300rpx;
  236. height: 72rpx;
  237. margin-top: 40rpx;
  238. font-size: 32rpx;
  239. background-color: #58be6b;
  240. color: #fff;
  241. border-radius: 44rpx;
  242. line-height: 72rpx;
  243. }
  244. }
  245. .ExchangeStation {
  246. display: flex;
  247. padding: 0 30rpx;
  248. flex-direction: column;
  249. .ExchangeTitle {
  250. display: flex;
  251. align-items: center;
  252. font-size: 28rpx;
  253. font-weight: 400;
  254. color: #86909C;
  255. margin-top: 20rpx;
  256. image {
  257. width: 28rpx;
  258. height: 28rpx;
  259. margin: 0rpx 10rpx;
  260. }
  261. }
  262. .Exchange-context {
  263. width: 100%;
  264. margin-top: 20rpx;
  265. display: flex;
  266. flex-direction: column;
  267. box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(226, 226, 226, 0.5);
  268. border-radius: 24rpx;
  269. padding: 0rpx 30rpx;
  270. box-sizing: border-box;
  271. background: #fff;
  272. .list {
  273. display: flex;
  274. height: 108rpx;
  275. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #E5E6EB;
  276. font-weight: 400;
  277. color: #1D2129;
  278. font-size: 32rpx;
  279. justify-content: space-between;
  280. align-items: center;
  281. }
  282. :last-child {
  283. box-shadow: none;
  284. }
  285. }
  286. }
  287. .Exchange-tips {
  288. margin-top: 38rpx;
  289. display: flex;
  290. flex-direction: column;
  291. padding: 0 30rpx;
  292. .tips-top {
  293. display: flex;
  294. font-weight: 400;
  295. color: #1D2129;
  296. font-size: 26rpx;
  297. align-items: center;
  298. image {
  299. width: 28rpx;
  300. height: 28rpx;
  301. margin: 0 10rpx;
  302. }
  303. }
  304. .tips-bottom {
  305. font-weight: 400;
  306. color: #86909C;
  307. font-size: 26rpx;
  308. line-height: 40rpx;
  309. margin-left: 10rpx;
  310. margin-top: 10rpx;
  311. }
  312. }
  313. .battery-info {
  314. display: flex;
  315. justify-content: space-between;
  316. padding: 0 80rpx;
  317. text-align: center;
  318. line-height: 36rpx;
  319. view>view:first-child {
  320. font-weight: bold;
  321. }
  322. view>view:last-child {
  323. color: #939da7;
  324. font-size: 26rpx;
  325. }
  326. }
  327. .carinfo {
  328. padding-left: 45rpx;
  329. width: 100%;
  330. box-sizing: border-box;
  331. margin-top: 90rpx;
  332. .battery-list {
  333. display: flex;
  334. width: 100%;
  335. margin-top: 36rpx;
  336. .icon {
  337. width: 55rpx;
  338. padding-top: 5rpx;
  339. image {
  340. width: 32rpx;
  341. height: 32rpx;
  342. }
  343. }
  344. .info {
  345. display: flex;
  346. flex: 1;
  347. border-bottom: #e5e5e5 solid 1px;
  348. justify-content: space-between;
  349. font-size: 28rpx;
  350. padding-bottom: 36rpx;
  351. padding-right: 40rpx;
  352. box-sizing: border-box;
  353. .word {
  354. color: #86909c;
  355. }
  356. .number {
  357. color: #333333;
  358. font-weight: bold;
  359. }
  360. }
  361. }
  362. }
  363. .submit {
  364. width: 600rpx;
  365. height: 88rpx;
  366. margin: 35rpx auto;
  367. font-size: 36rpx;
  368. background-color: #58be6b;
  369. color: #fff;
  370. border-radius: 44rpx;
  371. }
  372. </style>