address.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="address" style="padding-bottom: 150upx;">
  3. <!-- #ifdef MP-WEIXIN -->
  4. <view style="height: max-content;background-color: #FFFFFF;margin-top: 10upx;padding: 30upx 30upx 10upx 40upx;"
  5. v-for="(item,index) in list" :key='index'>
  6. <view @tap='goBackByAddress(item.addressId)'>
  7. <view class="flex align-center">
  8. <view class="text-bold" style="font-size: 38rpx;color: #333333;">{{item.name}}</view>
  9. <view style="font-size: 32rpx;color: #333333;margin-left: 20upx;text-align: right;">{{item.phone}}
  10. </view>
  11. </view>
  12. <view style="display: flex;margin-top: 35rpx;">
  13. <view style="font-size: 32rpx;color: #999999;width: 90%;">
  14. {{item.province}}{{item.city}}{{item.district}} {{item.detailsAddress}}
  15. </view>
  16. </view>
  17. </view>
  18. <view style="margin-top: 15upx;height: 1upx;background-color: #E3E4E5;margin-bottom: 10upx;"></view>
  19. <view style="display: flex;padding: 10rpx 2rpx 10rpx 0rpx;font-size: 32rpx;">
  20. <radio-group name="openWay" style="text-align: left;width: 70%;">
  21. <label class="tui-radio" v-if="item.isDefault == '1'">
  22. <radio :checked="item.isDefault == 1 ? true : false" active-color="#2FB57A" disabled='true'
  23. style="transform:scale(0.8);" />
  24. <text style="font-size: 32rpx;margin-left: 10upx;">默认地址</text>
  25. </label>
  26. </radio-group>
  27. <view style="display: flex;margin-left: 80upx;margin-top: 5upx;width: 40%;text-align: right;">
  28. <view style="font-size: 32rpx;color: #999999;width: 50%;" @tap='deleteAddressList(item.addressId)'>
  29. 删除</view>
  30. <view style="font-size: 32rpx;color: #999999;width: 50%;" @tap='goAddress(item.addressId)'>编辑</view>
  31. </view>
  32. </view>
  33. </view>
  34. <view style="position: fixed;bottom: 0rpx;left: 0;right: 0;background: #FFFFFF;height:150rpx;z-index: 999;">
  35. <button style="margin: 35rpx;position: fixed;bottom: 0upx;width: 686rpx;height: 100rpx;background: #2FB57A;color: #FFFFFF;border-radius: 86rpx 86rpx 86rpx 86rpx;"
  36. @tap="goAddress('')">
  37. +新建地址
  38. </button>
  39. </view>
  40. <empty v-if="list.length == 0"></empty>
  41. <!-- #endif -->
  42. <!-- #ifndef MP-WEIXIN -->
  43. <view style="width: 686rpx;background: #FFFFFF;border-radius: 32rpx 32rpx 32rpx 32rpx;margin: 0 32rpx 20rpx;padding: 24rpx;"
  44. v-for="(item,index) in list" :key='index'>
  45. <view @tap='goBackByAddress(item.addressId)'>
  46. <view style="display: flex;justify-content: space-between;font-weight: bold;font-size: 32rpx;color: #222222;">
  47. <view class="flex">
  48. <view class="">
  49. 用户名:
  50. </view>
  51. <view >{{item.name}}</view>
  52. </view>
  53. <view >{{item.phone}}
  54. </view>
  55. </view>
  56. <view style="display: flex;margin-top: 30upx;margin-bottom: 20rpx;">
  57. <view style="font-size: 28rpx;color: #AAAAAA;width: 90%;">
  58. {{item.province}}{{item.city}}{{item.district}} {{item.detailsAddress}}
  59. </view>
  60. </view>
  61. </view>
  62. <view style="margin-top: 10rpx;height: 1upx;background-color: #E3E4E5;margin-bottom: 10upx;"></view>
  63. <view style="display: flex;justify-content:space-between; 15upx 5upx 15upx 0upx;font-size: 30upx;width: 100%;margin-top: 20rpx;">
  64. <!-- <radio-group name="openWay" style="text-align: left;width: 70%;">
  65. <label class="tui-radio" v-if="item.isDefault == '1'">
  66. <radio :checked="item.isDefault == 1 ? true : false" color="#2FB57A" disabled='true'
  67. style="transform:scale(0.8);" />
  68. <text style="color: #07BF89;font-size: 28upx;margin-left: 10upx;">默认地址</text>
  69. </label>
  70. </radio-group> -->
  71. <text v-if="item.isDefault == '1'" style="color: #07BF89;font-size: 28upx;margin-left: 10upx;">默认地址</text>
  72. <view class="" v-else></view>
  73. <view style="display: flex;margin-top: 5upx;text-align: right;font-size: 28rpx;color: #AAAAAA;align-self: flex-end;">
  74. <view style="" @tap='deleteAddressList(item.addressId)'>
  75. 删除</view>
  76. <view style="margin-left: 30rpx;" @tap='goAddress(item.addressId)'>编辑</view>
  77. </view>
  78. </view>
  79. </view>
  80. <view style="position: fixed;bottom: 0rpx;left: 0;right: 0;background: #FFFFFF;height:150rpx;z-index: 999;">
  81. <button style="width: 686rpx;
  82. height: 100rpx;line-height: 100rpx;font-weight: bold;font-size: 32rpx;color: #222222;
  83. background: linear-gradient( 143deg, #FFE6EE 0%, #FF9AB2 100%);
  84. border-radius: 86rpx 86rpx 86rpx 86rpx;;margin: 30upx;position: fixed;bottom: 0upx;"
  85. @tap="goAddress('')">
  86. +新建地址
  87. </button>
  88. </view>
  89. <empty v-if="list.length == 0"></empty>
  90. <!-- #endif -->
  91. <!-- 悬浮上拉 -->
  92. <!-- <view class="scroll_top" @tap="topScrollTap" v-bind:class="[scrollTop ? 'active' : '', '']"
  93. style="bottom: 56px;"><text class="iconfont icon-shangla"></text></view> -->
  94. </view>
  95. </template>
  96. <script>
  97. import empty from '@/components/empty.vue'
  98. export default {
  99. components: {
  100. empty,
  101. },
  102. data() {
  103. return {
  104. openWay: 0,
  105. list: [],
  106. // loadingType: 0,
  107. type: 1,
  108. scrollTop: true,
  109. page: 1,
  110. limit: 5,
  111. address: '',
  112. isfa: ''
  113. }
  114. },
  115. onShow() {
  116. let userId = this.$queue.getData('userId');
  117. if (userId) {
  118. this.getAddressList();
  119. }
  120. },
  121. onLoad(e) {
  122. this.isfa = e.id
  123. let userId = this.$queue.getData('userId');
  124. if (userId) {
  125. this.getAddressList();
  126. }
  127. },
  128. methods: {
  129. goBackByAddress(addressId) {
  130. console.log(addressId)
  131. this.$queue.setData('EditAddress', addressId);
  132. console.log(this.isfa)
  133. if (this.isfa == 0) {
  134. console.log('1111111')
  135. }
  136. if (this.isfa == 1) {
  137. uni.navigateBack()
  138. } else if (this.isfa == 3) {
  139. this.updateaddress()
  140. }
  141. },
  142. updateaddress() {
  143. let addressId = this.$queue.getData('EditAddress')
  144. let data = {
  145. ordersId: this.isfa.order,
  146. addressId: addressId
  147. }
  148. this.$Request.post('/app/orders/updateOrdersAddress', data).then(res => {
  149. console.log(res)
  150. if (res.code == 0) {
  151. uni.showToast({
  152. title: '修改成功',
  153. icon: 'none'
  154. })
  155. uni.navigateBack();
  156. }
  157. })
  158. },
  159. deleteAddressList(id) {
  160. console.log(id)
  161. var id = id
  162. let data = {
  163. addressId: id,
  164. }
  165. uni.showModal({
  166. title: '温馨提示',
  167. content: '您确定要删除此地址信息吗?',
  168. showCancel: true,
  169. cancelText: '取消',
  170. confirmText: '确认',
  171. success: res => {
  172. if (res.confirm) {
  173. this.$Request.postT('/app/address/deleteAddress', data).then(res => {
  174. console.log(res)
  175. if (res.code == 0) {
  176. this.$queue.showToast("删除成功!");
  177. this.getAddressList();
  178. } else {
  179. this.$queue.showToast(res.msg);
  180. }
  181. });
  182. }
  183. }
  184. });
  185. },
  186. getAddressList() {
  187. uni.showLoading({
  188. title: '加载中...'
  189. });
  190. let userId = this.$queue.getData('userId');
  191. let data = {
  192. userId: userId,
  193. page: this.page,
  194. limit: this.limit
  195. }
  196. this.$Request.getT('/app/address/selectAddressListById', data).then(res => {
  197. uni.hideLoading();
  198. uni.stopPullDownRefresh();
  199. if (res.code == 0) {
  200. if (this.page == 1) this.list = []
  201. this.list = [...this.list, ...res.data.list]; //追加新数据
  202. this.list.forEach(item=>{
  203. if(item.isDefault == 1){
  204. return this.$queue.setData('EditAddress', item.addressId);
  205. }
  206. })
  207. }
  208. });
  209. },
  210. goAddress(id) {
  211. uni.navigateTo({
  212. url: '/my/address/Endaddress?id=' + id
  213. });
  214. },
  215. tabSlect(item) {
  216. this.tabIndex = item.id;
  217. },
  218. selectWay(id) {
  219. this.openWay = id;
  220. },
  221. },
  222. onReachBottom: function() {
  223. this.page = this.page + 1;
  224. this.getAddressList();
  225. },
  226. onPullDownRefresh: function() {
  227. this.page = 1;
  228. this.getAddressList();
  229. }
  230. }
  231. </script>
  232. <style lang="less">
  233. // @import '../../../static/less/index.less';
  234. // @import '../../../static/css/index.css';
  235. .address {
  236. background: #F6F6F6;
  237. height: calc(100vh - var(--window-top));
  238. padding-top: 20rpx;
  239. }
  240. .tui-line-cell {
  241. width: 100%;
  242. box-sizing: border-box;
  243. display: flex;
  244. align-items: center;
  245. justify-content: space-between;
  246. border-bottom: 2upx solid #f2f2f2;
  247. padding: 0 0 16upx 0;
  248. }
  249. .tui-title {
  250. line-height: 32rpx;
  251. min-width: 120rpx;
  252. flex-shrink: 0;
  253. }
  254. .tui-input {
  255. font-size: 32rpx;
  256. color: #333;
  257. padding-left: 20rpx;
  258. flex: 1;
  259. }
  260. </style>