address.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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: 35rpx;color: #333333;">{{item.name}}</view>
  9. <view style="font-size: 35rpx;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: 35rpx;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: 35rpx;">
  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="#20C675" disabled='true'
  23. style="transform:scale(0.8);" />
  24. <text style="font-size: 35rpx;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: 35rpx;color: #999999;width: 50%;" @tap='deleteAddressList(item.addressId)'>
  29. 删除</view>
  30. <view style="font-size: 35rpx;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: #20C675;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="#20C675" 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;">
  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;z-index: 999;background: #FFFFFF;height:150rpx;">
  73. <button style="background: #20C675;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. <empty v-if="list.length == 0" content="暂无地址信息" ></empty>
  83. </view>
  84. </template>
  85. <script>
  86. export default {
  87. data() {
  88. return {
  89. openWay: 0,
  90. list: [],
  91. // loadingType: 0,
  92. type: 1,
  93. scrollTop: false,
  94. page: 1,
  95. limit: 5,
  96. address: '',
  97. isfa: ''
  98. }
  99. },
  100. onShow() {
  101. let userId = this.$queue.getData('userId');
  102. if (userId) {
  103. this.getAddressList('');
  104. }
  105. },
  106. onLoad(e) {
  107. this.isfa = e.id
  108. console.log(this.isfa)
  109. let userId = this.$queue.getData('userId');
  110. if (userId) {
  111. this.getAddressList('');
  112. }
  113. },
  114. methods: {
  115. goBackByAddress(addressId) {
  116. console.log(addressId)
  117. this.$queue.setData('EditAddress', addressId);
  118. console.log(this.isfa)
  119. if (this.isfa==0) {
  120. console.log('1111111')
  121. }if(this.isfa ==1){
  122. uni.navigateBack()
  123. }else if(this.isfa== 3){
  124. this.updateaddress()
  125. // uni.navigateBack()
  126. }
  127. },
  128. updateaddress() {
  129. let addressId = this.$queue.getData('EditAddress')
  130. let data = {
  131. ordersId: this.isfa.order,
  132. addressId: addressId
  133. }
  134. this.$Request.post('/app/orders/updateOrdersAddress', data).then(res => {
  135. console.log(res)
  136. if (res.code == 0) {
  137. uni.showToast({
  138. title: '修改成功',
  139. icon: 'none'
  140. })
  141. uni.navigateBack();
  142. }
  143. })
  144. },
  145. deleteAddressList(id) {
  146. console.log(id)
  147. var id = id
  148. let data = {
  149. addressId: id,
  150. }
  151. uni.showModal({
  152. title: '温馨提示',
  153. content: '您确定要删除此地址信息吗?',
  154. showCancel: true,
  155. cancelText: '取消',
  156. confirmText: '确认',
  157. success: res => {
  158. if (res.confirm) {
  159. this.$Request.postT('/app/address/deleteAddress', data).then(res => {
  160. console.log(res)
  161. if (res.code == 0) {
  162. this.$queue.showToast("删除成功!");
  163. this.getAddressList();
  164. } else {
  165. this.$queue.showToast(res.msg);
  166. }
  167. });
  168. }
  169. }
  170. });
  171. },
  172. getAddressList(type) {
  173. // this.loadingType = 1;
  174. // uni.showLoading({
  175. // title: '加载中...'
  176. // });
  177. let userId = this.$queue.getData('userId');
  178. let data = {
  179. userId: userId,
  180. page: this.page,
  181. limit: this.limit
  182. }
  183. this.$Request.getT('/app/address/selectAddressListById', data).then(res => {
  184. console.log(res)
  185. if (res.code == 0) {
  186. if (this.page == 1) this.list = []
  187. this.list = [...this.list, ...res.data.list]; //追加新数据
  188. // res.data.list.forEach(d => {
  189. // this.list.push(d);
  190. // });
  191. // console.log(this.list)
  192. // this.loadingType = 0;
  193. } else {
  194. // this.loadingType = 2;
  195. }
  196. // uni.hideLoading();
  197. // if (type === 'Refresh') {
  198. // uni.stopPullDownRefresh(); // 停止刷新
  199. // }
  200. });
  201. },
  202. goAddress(id) {
  203. uni.navigateTo({
  204. // url: './EditAddress?id=' + id
  205. url: '/my/address/Endaddress?id=' + id
  206. });
  207. },
  208. tabSlect(item) {
  209. this.tabIndex = item.id;
  210. },
  211. selectWay(id) {
  212. this.openWay = id;
  213. },
  214. topScrollTap: function() {
  215. uni.pageScrollTo({
  216. scrollTop: 0,
  217. duration: 300
  218. });
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="less">
  224. @import '../../static/less/index.less';
  225. @import '../../static/css/index.css';
  226. page {
  227. background: #F2F2F2;
  228. }
  229. .tui-line-cell {
  230. width: 100%;
  231. box-sizing: border-box;
  232. display: flex;
  233. align-items: center;
  234. justify-content: space-between;
  235. border-bottom: 2upx solid #f2f2f2;
  236. padding: 0 0 16upx 0;
  237. }
  238. .tui-title {
  239. line-height: 32rpx;
  240. min-width: 120rpx;
  241. flex-shrink: 0;
  242. }
  243. .tui-input {
  244. font-size: 32rpx;
  245. color: #333;
  246. padding-left: 20rpx;
  247. flex: 1;
  248. }
  249. </style>