carList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <view class="car-list">
  3. <view v-for="(item,index) of carList" :key="index" @click="clickItem(item)" class="car-list-card" :class="{ 'car-list-card-i' : car_info.car_sn == item.car_sn}">
  4. <view class="car-name" :class="{ 'car-name-i' : car_info.car_sn == item.car_sn}">{{item.car_name}}</view>
  5. <image v-if="car_info.car_sn == item.car_sn" class="icon" src="/static/resource/images/gyq_ly.png" mode=""></image>
  6. <!-- https://qiniu.bms16.com/Fg8_p7083jpsy8BXG4bR6yMs7jQX -->
  7. <image class="img" :src="item.model_images" mode="aspectFit"></image>
  8. <view v-if="car_info.car_sn == item.car_sn" class="select">
  9. <image class="icon1" src="/static/resource/images/gyq_select.png" mode=""></image>
  10. <text>当前选择</text>
  11. </view>
  12. </view>
  13. <view class="options">
  14. <view @click="navCarDetail" class="btn btn-left">{{ $t('租赁设备') }}</view>
  15. <view class="btn btn-right">{{ $t('绑定设备') }}</view>
  16. </view>
  17. <Confirm
  18. v-model="showConfirm"
  19. :dialog-info="{
  20. text: $t('是否确定'),
  21. showCancelButton: true
  22. }"
  23. @confirm="unbindSubmit"
  24. />
  25. </view>
  26. </template>
  27. <script>
  28. import Confirm from '@/component/comPopup/Confirm'
  29. var config = require('../../common/config.js');
  30. var app = getApp();
  31. var config = require('../../common/config.js');
  32. var common = require('../../common/common.js');
  33. var http = require('../../common/http.js');
  34. var storage = require('../../common/storage.js');
  35. export default {
  36. components: {
  37. Confirm,
  38. },
  39. data() {
  40. return {
  41. showConfirm: false,
  42. carList:[],
  43. car_sn:"",
  44. car_info:{},
  45. clickItemData:{}
  46. };
  47. }
  48. /**
  49. * 生命周期函数--监听页面加载
  50. */
  51. ,
  52. onLoad: function(options) {
  53. this.loadUserCarList()
  54. },
  55. methods: {
  56. navCarDetail(){
  57. // const me=this
  58. // uni.navigateTo({
  59. // url: '/pages/carDetail/carDetail'
  60. // })
  61. },
  62. clickItem(item){
  63. if(item.car_sn == this.car_info.car_sn) return
  64. this.clickItemData = item
  65. // console.log(item);
  66. this.showConfirm = true
  67. // uni.setStorageSync('car_info',item)
  68. // this.car_info = item
  69. },
  70. unbindSubmit(){
  71. let car_sn = this.clickItemData.car_sn
  72. if(!car_sn) return
  73. const me = this
  74. common.loading()
  75. http.postApi(config.API_FLK_CAR_DETAIL, {car_sn}, (resp) => {
  76. uni.hideLoading();
  77. if (resp.data.code === 200) {
  78. resp.data.data.car_sn = car_sn
  79. uni.setStorageSync('car_info', resp.data.data);
  80. me.car_info = resp.data.data
  81. common.simpleToast('切换成功!')
  82. setTimeout(()=> {
  83. uni.navigateBack({
  84. delta:1
  85. })
  86. }, 900)
  87. } else {
  88. common.simpleToast(resp.data.msg);
  89. }
  90. })
  91. },
  92. loadUserCarList(){
  93. this.car_info = uni.getStorageSync('car_info') || {};
  94. const me = this
  95. common.loading()
  96. http.postApi(config.API_FLK_CAR_DEVICE_LIST, {}, (resp) => {
  97. uni.hideLoading();
  98. if (resp.data.code === 200) {
  99. const carList=resp.data.data.list
  100. me.setData({
  101. carList,
  102. })
  103. } else {
  104. common.simpleToast(resp.data.msg);
  105. }
  106. })
  107. },
  108. }
  109. };
  110. </script>
  111. <style lang="scss" scoped>
  112. .car-list{
  113. padding: 24rpx;
  114. }
  115. .car-list-card{
  116. width:100%;
  117. height: 596rpx;
  118. background: linear-gradient( 135deg, #DEE0E8 0%, rgba(255,255,255,0.4) 50%, #F1F3F4 100%);
  119. border-radius: 40rpx;
  120. border: 6rpx solid #FFF;
  121. position: relative;
  122. padding: 30rpx;
  123. .select{
  124. position: absolute;
  125. right: 0;
  126. top: 0;
  127. width: 164rpx;
  128. height: 78rpx;
  129. text-align: center;
  130. .icon1{
  131. width: 164rpx;
  132. height: 78rpx;
  133. position: absolute;
  134. left: 0;
  135. top: 0;
  136. }
  137. text{
  138. position: relative;
  139. z-index: 1;
  140. font-family: PingFangSC, PingFang SC;
  141. font-weight: 600;
  142. font-size: 28rpx;
  143. color: #FFFFFF;
  144. line-height: 28rpx;
  145. margin-top: 10rpx;
  146. display: block;
  147. }
  148. }
  149. .icon{
  150. position: absolute;
  151. width: 48rpx;
  152. height: 48rpx;
  153. left: 30rpx;
  154. top: 120rpx;
  155. }
  156. .img{
  157. width: 520rpx;
  158. height: 400rpx;
  159. display: block;
  160. margin: auto;
  161. margin-top: 40rpx;
  162. }
  163. }
  164. .car-list-card-i{
  165. background: linear-gradient( 135deg, #DEEAFF 0%, rgba(220,244,251,0.4) 50%, #DAFFF6 100%);
  166. }
  167. .car-name{
  168. font-family: PingFangSC, PingFang SC;
  169. font-weight: 600;
  170. font-size: 48rpx;
  171. color: #828DA2;
  172. }
  173. .car-name-i{
  174. color: #060809;
  175. }
  176. .options {
  177. padding: 0 28rpx;
  178. display: flex;
  179. justify-content: space-between;
  180. margin-bottom: 44rpx;
  181. margin-top: 44rpx;
  182. .btn {
  183. width: 336rpx;
  184. height: 98rpx;
  185. border-radius: 50rpx;
  186. border: 4rpx solid #060809;
  187. font-size: 36rpx;
  188. display: flex;
  189. align-items: center;
  190. justify-content: center;
  191. }
  192. .btn-left {
  193. color: #060809;
  194. background: rgba(255, 255, 255, 0.6);
  195. margin-right: 22rpx;
  196. }
  197. .btn-right {
  198. color: #fff;
  199. background: #060809;
  200. }
  201. }
  202. </style>