cailist.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. }
  182. .saveCar {
  183. background: linear-gradient(135deg, #FD5300 0%, #FF270A 100%);
  184. margin: 23rpx 30rpx;
  185. height: 74rpx;
  186. border-radius: 37rpx;
  187. color: #FFFFFF;
  188. font-size: 30rpx;
  189. font-weight: bold;
  190. align-items: center;
  191. display: flex;
  192. justify-content: center;
  193. }
  194. .carlistBox {
  195. padding-bottom: 120rpx;
  196. }
  197. .carlistBox {
  198. padding: 24rpx;
  199. padding-bottom: 120rpx;
  200. }
  201. .brandLogo {
  202. width: 63rpx;
  203. }
  204. .line {
  205. background: #FFFFFF;
  206. padding: 27rpx 20rpx;
  207. border-radius: 10rpx;
  208. margin-bottom: 20rpx;
  209. position: relative;
  210. }
  211. .lineCont {
  212. display: flex;
  213. }
  214. .carName {
  215. color: #3C3C3C;
  216. font-size: 30rpx;
  217. display: flex;
  218. }
  219. .plateNumber {
  220. border-radius: 4px;
  221. border: 1px solid #F19D01;
  222. height: 32rpx;
  223. line-height: 32rpx;
  224. padding: 0 10rpx;
  225. color: #F19D01;
  226. font-size: 22rpx;
  227. margin-left: 20rpx;
  228. margin-top: 5rpx;
  229. }
  230. .carMS {
  231. color: #666666;
  232. font-size: 26rpx;
  233. padding-top: 5px;
  234. }
  235. .lineBottom {
  236. display: flex;
  237. justify-content: flex-end;
  238. padding-top: 20rpx;
  239. }
  240. .lineDel {
  241. width: 94rpx;
  242. height: 50rpx;
  243. border-radius: 25rpx;
  244. border: 1px solid #DDDDDD;
  245. text-align: center;
  246. line-height: 50rpx;
  247. font-size: 26rpx;
  248. color: #3C3C3C;
  249. margin-right: 29rpx;
  250. }
  251. .Default {
  252. width: 148rpx;
  253. height: 50rpx;
  254. border-radius: 25rpx;
  255. border: 1px solid #FF4F00;
  256. line-height: 50rpx;
  257. text-align: center;
  258. color: #FF4F00;
  259. font-size: 26rpx;
  260. }
  261. .DefaultYES {
  262. width: 148rpx;
  263. height: 50rpx;
  264. border-radius: 25rpx;
  265. border: 1px solid #DDDDDD;
  266. line-height: 50rpx;
  267. text-align: center;
  268. color: #999999;
  269. font-size: 26rpx;
  270. }
  271. .DefaultIcon {
  272. position: absolute;
  273. top: 0;
  274. right: 0;
  275. width: 109rpx;
  276. height: 40rpx;
  277. background: linear-gradient(131deg, #FFA72C 0%, #FF450F 100%);
  278. border-radius: 0px 10rpx 0px 10rpx;
  279. text-align: center;
  280. line-height: 40rpx;
  281. color: #FFFFFF;
  282. font-size: 22rpx;
  283. }
  284. </style>