cailist.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. title: '加载中'
  64. })
  65. this.loding = false;
  66. this.$http('worldKeepCar/worldHome/queryMyTMemberCar', {
  67. }, 'GET').then(res => {
  68. uni.hideLoading();
  69. this.carList = res.data;
  70. this.loding = true;
  71. })
  72. },
  73. addBtn() {
  74. var length = this.carList.length
  75. if (length > 4) {
  76. uni.showToast({
  77. title: '库最多放五辆车,如果想添加,请先删除',
  78. icon: 'none',
  79. duration: 3000
  80. });
  81. } else {
  82. uni.navigateTo({
  83. url: 'addCar'
  84. })
  85. }
  86. },
  87. editCar(id) {
  88. uni.navigateTo({
  89. url: 'addCar?id=' + id + '&isEditCar=true'
  90. })
  91. },
  92. delCar(id) {
  93. var that = this;
  94. uni.showModal({
  95. title: '提示',
  96. content: '确定要删除车辆吗',
  97. success: function(res) {
  98. if (res.confirm) {
  99. uni.showLoading({});
  100. that.$http('worldKeepCar/worldHome/deleteTMemberCar', {
  101. id: id
  102. }, 'POST').then(res => {
  103. uni.hideLoading();
  104. if (res.code == 0) {
  105. if (that.carId == id) {
  106. uni.removeStorageSync('maintainCarData');
  107. }
  108. }
  109. that.getqueryMyBMemberCar()
  110. })
  111. } else if (res.cancel) {
  112. }
  113. }
  114. });
  115. },
  116. defaultCar(item) {
  117. var that = this;
  118. uni.showLoading({
  119. title: '保存中'
  120. })
  121. that.$http('worldKeepCar/worldHome/updateTCarIsdefault', {
  122. id: item.id
  123. }, 'POST').then(res => {
  124. uni.hideLoading();
  125. if (res.code == 0) {
  126. uni.showToast({
  127. title: '操作成功',
  128. icon: 'none',
  129. duration: 3000
  130. });
  131. } else {
  132. uni.showToast({
  133. title: res.msg,
  134. icon: 'none',
  135. duration: 3000
  136. });
  137. }
  138. that.getqueryMyBMemberCar()
  139. })
  140. },
  141. itemClick(item) {
  142. if (this.fromMe == 'true') {
  143. return
  144. }
  145. uni.setStorage({
  146. key: 'maintainCarData',
  147. data: item,
  148. success: function() {
  149. uni.navigateBack({
  150. delta: 1
  151. })
  152. }
  153. });
  154. }
  155. }
  156. }
  157. </script>
  158. <style scoped>
  159. .box {
  160. min-height: 100vh;
  161. background: #F4F5F7;
  162. }
  163. .nodataImg {
  164. width: 400rpx;
  165. padding-top: 100rpx;
  166. }
  167. .noTxt {
  168. font-size: 36rpx;
  169. color: #999999;
  170. padding-top: 50rpx;
  171. }
  172. .nodataBox {
  173. text-align: center;
  174. }
  175. .bottomView {
  176. background-color: #FFFFFF;
  177. width: 100%;
  178. height: 120rpx;
  179. position: fixed;
  180. bottom: 0rpx;
  181. padding-bottom: constant(safe-area-inset-bottom);
  182. padding-bottom: env(safe-area-inset-bottom);
  183. }
  184. .saveCar {
  185. background: linear-gradient(135deg, #FD5300 0%, #FF270A 100%);
  186. margin: 23rpx 30rpx;
  187. height: 74rpx;
  188. border-radius: 37rpx;
  189. color: #FFFFFF;
  190. font-size: 30rpx;
  191. font-weight: bold;
  192. align-items: center;
  193. display: flex;
  194. justify-content: center;
  195. }
  196. .carlistBox {
  197. padding-bottom: 120rpx;
  198. }
  199. .carlistBox {
  200. padding: 24rpx;
  201. padding-bottom: 120rpx;
  202. }
  203. .brandLogo {
  204. width: 63rpx;
  205. }
  206. .line {
  207. background: #FFFFFF;
  208. padding: 27rpx 20rpx;
  209. border-radius: 10rpx;
  210. margin-bottom: 20rpx;
  211. position: relative;
  212. }
  213. .lineCont {
  214. display: flex;
  215. }
  216. .carName {
  217. color: #3C3C3C;
  218. font-size: 30rpx;
  219. display: flex;
  220. }
  221. .plateNumber {
  222. border-radius: 4px;
  223. border: 1px solid #F19D01;
  224. height: 32rpx;
  225. line-height: 32rpx;
  226. padding: 0 10rpx;
  227. color: #F19D01;
  228. font-size: 22rpx;
  229. margin-left: 20rpx;
  230. margin-top: 5rpx;
  231. }
  232. .carMS {
  233. color: #666666;
  234. font-size: 26rpx;
  235. padding-top: 5px;
  236. }
  237. .lineBottom {
  238. display: flex;
  239. justify-content: flex-end;
  240. padding-top: 20rpx;
  241. }
  242. .lineDel {
  243. width: 94rpx;
  244. height: 50rpx;
  245. border-radius: 25rpx;
  246. border: 1px solid #DDDDDD;
  247. text-align: center;
  248. line-height: 50rpx;
  249. font-size: 26rpx;
  250. color: #3C3C3C;
  251. margin-right: 29rpx;
  252. }
  253. .Default {
  254. width: 148rpx;
  255. height: 50rpx;
  256. border-radius: 25rpx;
  257. border: 1px solid #FF4F00;
  258. line-height: 50rpx;
  259. text-align: center;
  260. color: #FF4F00;
  261. font-size: 26rpx;
  262. }
  263. .DefaultYES {
  264. width: 148rpx;
  265. height: 50rpx;
  266. border-radius: 25rpx;
  267. border: 1px solid #DDDDDD;
  268. line-height: 50rpx;
  269. text-align: center;
  270. color: #999999;
  271. font-size: 26rpx;
  272. }
  273. .DefaultIcon {
  274. position: absolute;
  275. top: 0;
  276. right: 0;
  277. width: 109rpx;
  278. height: 40rpx;
  279. background: linear-gradient(131deg, #FFA72C 0%, #FF450F 100%);
  280. border-radius: 0px 10rpx 0px 10rpx;
  281. text-align: center;
  282. line-height: 40rpx;
  283. color: #FFFFFF;
  284. font-size: 22rpx;
  285. }
  286. </style>