cailist.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view class="box">
  3. <view class="carlistBox">
  4. <view class="line" v-for="(item,index) in carList" @click="itemClick(item)">
  5. <view class="lineCont">
  6. <view>
  7. <image :src="item.brandLogo" mode="widthFix" class="brandLogo"></image>
  8. </view>
  9. <view style="padding-left: 29rpx;">
  10. <view class="carName">
  11. <span>{{item.brand}} {{item.series}}</span>
  12. <view class="plateNumber">{{item.plateNumber}}</view>
  13. </view>
  14. <view class="carMS">{{item.carModel}}</view>
  15. </view>
  16. </view>
  17. <view class="lineBottom">
  18. <view class="lineDel" @click.stop="delCar(item.id)">删除</view>
  19. <view class="lineDel" @click.stop="editCar(item.id)">编辑</view>
  20. <view class="Default" v-show="item.isDefault!=1" @click.stop="defaultCar(item)">设为默认</view>
  21. <view class="DefaultYES" v-show="item.isDefault==1">已设为默认</view>
  22. </view>
  23. <view class="DefaultIcon" v-show="item.isDefault==1">默认</view>
  24. </view>
  25. </view>
  26. <view v-if="carList==''&&loding" class="nodataBox">
  27. <image src="../../static/img/nodata.png" mode="widthFix" class="nodataImg"></image>
  28. <view class="noTxt">暂无数据</view>
  29. </view>
  30. <view class="bottomView">
  31. <view class="saveCar" @click="addBtn">
  32. <image src="../../static/img/icon_tianjiacheliang.png" mode=""
  33. style="width: 44rpx; height: 36rpx; margin-right: 10rpx;"></image>
  34. <view>添加爱车</view>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. carList: '',
  44. loding: false,
  45. type: '',
  46. carId: '',
  47. fromMe: false,
  48. }
  49. },
  50. onLoad(opt) {
  51. this.$common.isUserId()
  52. this.type = opt.type;
  53. // console.log(this.type)
  54. this.fromMe = opt.fromMe
  55. },
  56. onShow() {
  57. this.getqueryMyBMemberCar();
  58. this.carId = uni.getStorageSync("maintainCarData").id
  59. },
  60. methods: {
  61. getqueryMyBMemberCar() {
  62. uni.showLoading({});
  63. this.loding = false;
  64. this.$http('worldKeepCar/worldHome/queryMyTMemberCar', {
  65. }, 'GET').then(res => {
  66. uni.hideLoading();
  67. this.carList = res.data;
  68. this.loding = true;
  69. })
  70. },
  71. addBtn() {
  72. var length = this.carList.length
  73. if (length > 4) {
  74. uni.showToast({
  75. title: '库最多放五辆车,如果想添加,请先删除',
  76. icon: 'none',
  77. duration: 3000
  78. });
  79. } else {
  80. uni.navigateTo({
  81. url: 'addCar'
  82. })
  83. }
  84. },
  85. editCar(id) {
  86. uni.navigateTo({
  87. url: 'addCar?id=' + id + '&isEditCar=true'
  88. })
  89. },
  90. delCar(id) {
  91. var that = this;
  92. uni.showModal({
  93. title: '提示',
  94. content: '确定要删除车辆吗',
  95. success: function(res) {
  96. if (res.confirm) {
  97. uni.showLoading({});
  98. that.$http('worldKeepCar/worldHome/deleteTMemberCar', {
  99. id: id
  100. }, 'POST').then(res => {
  101. uni.hideLoading();
  102. if (res.code == 0) {
  103. if (that.carId == id) {
  104. uni.removeStorageSync('maintainCarData');
  105. }
  106. }
  107. that.getqueryMyBMemberCar()
  108. })
  109. } else if (res.cancel) {
  110. }
  111. }
  112. });
  113. },
  114. defaultCar(item) {
  115. var that = this;
  116. uni.showLoading({});
  117. that.$http('worldKeepCar/worldHome/updateTCarIsdefault', {
  118. id: item.id
  119. }, 'POST').then(res => {
  120. uni.hideLoading();
  121. if (res.code == 0) {
  122. uni.showToast({
  123. title: '操作成功',
  124. icon: 'none',
  125. duration: 3000
  126. });
  127. } else {
  128. uni.showToast({
  129. title: res.msg,
  130. icon: 'none',
  131. duration: 3000
  132. });
  133. }
  134. that.getqueryMyBMemberCar()
  135. })
  136. },
  137. itemClick(item) {
  138. if (this.fromMe == 'true') {
  139. return
  140. }
  141. uni.setStorage({
  142. key: 'maintainCarData',
  143. data: item,
  144. success: function() {
  145. uni.navigateBack({
  146. delta: 1
  147. })
  148. }
  149. });
  150. }
  151. }
  152. }
  153. </script>
  154. <style scoped>
  155. .box {
  156. min-height: 100vh;
  157. background: #F4F5F7;
  158. }
  159. .nodataImg {
  160. width: 400rpx;
  161. padding-top: 100rpx;
  162. }
  163. .noTxt {
  164. font-size: 36rpx;
  165. color: #999999;
  166. padding-top: 50rpx;
  167. }
  168. .nodataBox {
  169. text-align: center;
  170. }
  171. .bottomView {
  172. background-color: #FFFFFF;
  173. width: 100%;
  174. height: 120rpx;
  175. position: fixed;
  176. bottom: 0rpx;
  177. }
  178. .saveCar {
  179. background: linear-gradient(135deg, #FD5300 0%, #FF270A 100%);
  180. margin: 23rpx 30rpx;
  181. height: 74rpx;
  182. border-radius: 37rpx;
  183. color: #FFFFFF;
  184. font-size: 30rpx;
  185. font-weight: bold;
  186. align-items: center;
  187. display: flex;
  188. justify-content: center;
  189. }
  190. .carlistBox {
  191. padding-bottom: 120rpx;
  192. }
  193. .carlistBox {
  194. padding: 24rpx;
  195. padding-bottom: 120rpx;
  196. }
  197. .brandLogo {
  198. width: 63rpx;
  199. }
  200. .line {
  201. background: #FFFFFF;
  202. padding: 27rpx 20rpx;
  203. border-radius: 10rpx;
  204. margin-bottom: 20rpx;
  205. position: relative;
  206. }
  207. .lineCont {
  208. display: flex;
  209. }
  210. .carName {
  211. color: #3C3C3C;
  212. font-size: 30rpx;
  213. display: flex;
  214. }
  215. .plateNumber {
  216. border-radius: 4px;
  217. border: 1px solid #F19D01;
  218. height: 32rpx;
  219. line-height: 32rpx;
  220. padding: 0 10rpx;
  221. color: #F19D01;
  222. font-size: 22rpx;
  223. margin-left: 20rpx;
  224. margin-top: 5rpx;
  225. width: 120rpx;
  226. }
  227. .carMS {
  228. color: #666666;
  229. font-size: 26rpx;
  230. padding-top: 5px;
  231. }
  232. .lineBottom {
  233. display: flex;
  234. justify-content: flex-end;
  235. padding-top: 20rpx;
  236. }
  237. .lineDel {
  238. width: 94rpx;
  239. height: 50rpx;
  240. border-radius: 25rpx;
  241. border: 1px solid #DDDDDD;
  242. text-align: center;
  243. line-height: 50rpx;
  244. font-size: 26rpx;
  245. color: #3C3C3C;
  246. margin-right: 29rpx;
  247. }
  248. .Default {
  249. width: 148rpx;
  250. height: 50rpx;
  251. border-radius: 25rpx;
  252. border: 1px solid #FF4F00;
  253. line-height: 50rpx;
  254. text-align: center;
  255. color: #FF4F00;
  256. font-size: 26rpx;
  257. }
  258. .DefaultYES {
  259. width: 148rpx;
  260. height: 50rpx;
  261. border-radius: 25rpx;
  262. border: 1px solid #DDDDDD;
  263. line-height: 50rpx;
  264. text-align: center;
  265. color: #999999;
  266. font-size: 26rpx;
  267. }
  268. .DefaultIcon {
  269. position: absolute;
  270. top: 0;
  271. right: 0;
  272. width: 109rpx;
  273. height: 40rpx;
  274. background: linear-gradient(131deg, #FFA72C 0%, #FF450F 100%);
  275. border-radius: 0px 10rpx 0px 10rpx;
  276. text-align: center;
  277. line-height: 40rpx;
  278. color: #FFFFFF;
  279. font-size: 22rpx;
  280. }
  281. </style>