address.vue 7.6 KB

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