cailist.vue 6.1 KB

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