point.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <view class="content b-t">
  3. <view class="list" v-for="(item, index) in addressList" :key="index" @click="checkAddress(item)">
  4. <view class="wrapper">
  5. <view class="address-box">
  6. <text class="name">{{ item.name }}</text>
  7. <!-- <text class="mobile">{{ item.phone }}</text> -->
  8. </view>
  9. <view class="u-box">
  10. <text class="address">营业时间:{{item.day_time}}</text>
  11. </view>
  12. <view class="u-box">
  13. <text class="address">地址:{{ item.address }} {{ item.detailed_address }}</text>
  14. </view>
  15. <view class="u-box">
  16. <text class="address">电话:{{item.phone}}</text>
  17. </view>
  18. </view>
  19. <view class="buttom">
  20. <!-- <view class="default-buttom" @click.stop="defaultUp(item,index)">
  21. <view class="iconfont iconroundcheckfill checkbox" :class="{ checked: item.is_default == 1 }"></view>
  22. <text class="text">设为默认地址</text>
  23. </view> -->
  24. <view class="operation">
  25. <view @click.stop="addAddress('edit', item)">
  26. <text class="iconfont iconedit"></text>
  27. <text class="text">编辑</text>
  28. </view>
  29. <view class="blank"></view>
  30. <view @click.stop="delAddress(item)">
  31. <text class="iconfont icondelete"></text>
  32. <text class="text">删除</text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <button class="add-btn" @click="addAddress('add')">新增自提点</button>
  38. </view>
  39. </template>
  40. <script>
  41. import { getAddressList,setAddressDefault,addressDel ,getPoint, delPoint} from '@/api/user.js';
  42. export default {
  43. data() {
  44. return {
  45. source: 0,
  46. addressList: []
  47. };
  48. },
  49. onLoad(option) {
  50. this.source = option.source||0
  51. this.loadAddress();
  52. },
  53. methods: {
  54. // 加载地址
  55. loadAddress() {
  56. uni.showLoading({
  57. title: '加载中...',
  58. mask: true
  59. })
  60. getPoint({
  61. page: 1,
  62. limit: 100
  63. }).then(({data}) => {
  64. uni.hideLoading()
  65. console.log(data.data,'point++++++++++++++++')
  66. this.addressList = data.data;
  67. }).catch( err => {
  68. uni.hideLoading()
  69. console.log(err)
  70. })
  71. },
  72. // 设为默认地址
  73. defaultUp(data,ind) {
  74. this.addressList=this.addressList.map((e) => {
  75. e.is_default=0
  76. return e
  77. })
  78. this.addressList[ind].is_default=1
  79. setAddressDefault({
  80. id: data.id
  81. }).then(({ data }) => {
  82. this.loadAddress();
  83. }).catch((e) => {
  84. console.log(e);
  85. });
  86. },
  87. //删除地址
  88. delAddress(item) {
  89. delPoint({},item.id).then(({data})=>{
  90. this.$api.msg('删除成功')
  91. })
  92. let s = this.addressList.indexOf(item);
  93. this.addressList.splice(s, 1);
  94. },
  95. //选择地址
  96. checkAddress(item) {
  97. if (this.source == 1) {
  98. //this.$api.prePage()获取上一页实例,在App.vue定义
  99. this.$api.prePage().addressData = item;
  100. console.log(this.$api.prePage().addressData,'99999999+++++++++99999999999')
  101. uni.navigateBack();
  102. }
  103. },
  104. // 添加地址
  105. addAddress(type, item) {
  106. uni.navigateTo({
  107. url: `/pages/set/pointManage?type=${type}&data=${JSON.stringify(item)}`
  108. });
  109. },
  110. //添加或修改成功之后回调
  111. refreshList() {
  112. // 重新加载地址
  113. this.loadAddress()
  114. }
  115. }
  116. };
  117. </script>
  118. <style lang="scss">
  119. page {
  120. padding-bottom: 120rpx;
  121. padding-top: 20rpx;
  122. background-color: $page-color-base;
  123. }
  124. .content {
  125. position: relative;
  126. }
  127. .list {
  128. align-items: center;
  129. padding: 20rpx 30rpx;
  130. background: #fff;
  131. margin: 20rpx;
  132. margin-top: 0;
  133. .buttom {
  134. display: flex;
  135. align-items: center;
  136. justify-content: flex-end;
  137. padding-top: 10rpx;
  138. .checkbox {
  139. font-size: 44rpx;
  140. line-height: 1;
  141. padding: 4rpx;
  142. color: $font-color-disabled;
  143. background: #fff;
  144. border-radius: 50px;
  145. }
  146. .checkbox.checked {
  147. color: $base-color;
  148. }
  149. .default-buttom {
  150. display: flex;
  151. align-items: center;
  152. }
  153. .operation {
  154. display: flex;
  155. align-items: center;
  156. .blank {
  157. width: 30rpx;
  158. }
  159. }
  160. .text {
  161. padding-left: 10rpx;
  162. font-size: 24rpx;
  163. color: #666666;
  164. }
  165. }
  166. }
  167. .wrapper {
  168. display: flex;
  169. flex-direction: column;
  170. flex: 1;
  171. border-bottom: 1px solid #f0f0f0;
  172. padding-bottom: 20rpx;
  173. }
  174. .address-box {
  175. display: flex;
  176. align-items: center;
  177. justify-content: space-between;
  178. .address {
  179. font-size: $font-base + 2rpx;
  180. color: $font-color-dark;
  181. }
  182. .mobile {
  183. font-size: $font-base;
  184. color: rgba(51, 51, 51, 1);
  185. }
  186. }
  187. .u-box {
  188. font-size: $font-base;
  189. color: $font-color-light;
  190. margin-top: 16rpx;
  191. .name {
  192. margin-right: 30rpx;
  193. }
  194. }
  195. .icon-bianji {
  196. display: flex;
  197. align-items: center;
  198. height: 80rpx;
  199. font-size: 40rpx;
  200. color: $font-color-light;
  201. padding-left: 30rpx;
  202. }
  203. .add-btn {
  204. position: fixed;
  205. left: 30rpx;
  206. right: 30rpx;
  207. bottom: 16rpx;
  208. z-index: 95;
  209. display: flex;
  210. align-items: center;
  211. justify-content: center;
  212. width: 690rpx;
  213. height: 80rpx;
  214. font-size: $font-lg;
  215. color: #fff;
  216. background-color: $base-color;
  217. border-radius: 10rpx;
  218. }
  219. </style>