cailist.vue 5.9 KB

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