address.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <view v-for="(item,index) in address" :key="index" @click.stop="selectAddress(item)" class="address-item" >
  5. <view class="info" >
  6. <view class="title">
  7. <view v-if="item.isDefault == 1" class="tag">默认</view>
  8. {{item.province}}{{item.city}}{{item.district}}{{item.detail}}
  9. </view>
  10. <view class="name-phone">
  11. <text class="text">{{item.realName}}</text>
  12. <text class="text">{{$parsePhone(item.phone)}}</text>
  13. </view>
  14. </view>
  15. <view class="operat-box">
  16. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/del.png" mode="" @click.stop="delAddress(item)"></image>
  17. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/edit.png" mode="" @click.stop="editAddress(item)"></image>
  18. </view>
  19. </view>
  20. <view v-if="address.length == 0" class="no-data-box" @click="getAddressList()">
  21. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/empty_icon.png" mode="aspectFit"></image>
  22. <view class="empty-title">暂无数据</view>
  23. </view>
  24. </view>
  25. <view class="btn-box">
  26. <view class="sub-btn" @click="addAddress()">新建收货地址</view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import {getAddressList,delAddress} from '@/api/userAddress'
  32. export default {
  33. data() {
  34. return {
  35. address:[],
  36. }
  37. },
  38. //发送给朋友
  39. onShareAppMessage(res) {
  40. return {
  41. title: '新建收货地址',
  42. path: '/pages_user/address',
  43. }
  44. },
  45. onLoad() {
  46. var that=this;
  47. uni.$on('refreshAddress', () => {
  48. that.getAddressList()
  49. })
  50. },
  51. onShow() {
  52. this.getAddressList()
  53. },
  54. methods: {
  55. selectAddress(item){
  56. uni.$emit('updateAddress',item);
  57. uni.navigateBack({
  58. delta: 1
  59. })
  60. },
  61. editAddress(item){
  62. uni.navigateTo({
  63. url: './addEditAddress?type=edit&addressId='+item.addressId
  64. })
  65. },
  66. delAddress(item){
  67. uni.showModal({
  68. title:"提示",
  69. content:"确认删除此地址吗?",
  70. showCancel:true,
  71. cancelText:'取消',
  72. confirmText:'确定',
  73. success:res=>{
  74. if(res.confirm){
  75. // 用户点击确定
  76. var data={addressId:item.addressId}
  77. delAddress(data).then(
  78. res => {
  79. if(res.code==200){
  80. uni.showToast({
  81. icon:'success',
  82. title: "操作成功",
  83. });
  84. this.getAddressList()
  85. }else{
  86. uni.showToast({
  87. icon:'none',
  88. title: "请求失败",
  89. });
  90. }
  91. },
  92. rej => {}
  93. );
  94. }else{
  95. // 否则点击了取消
  96. }
  97. }
  98. })
  99. },
  100. getAddressList(){
  101. getAddressList().then(
  102. res => {
  103. if(res.code==200){
  104. this.address=res.data;
  105. }else{
  106. uni.showToast({
  107. icon:'none',
  108. title: "请求失败",
  109. });
  110. }
  111. },
  112. rej => {}
  113. );
  114. },
  115. // 新建地址
  116. addAddress() {
  117. uni.navigateTo({
  118. url: './addEditAddress?type=add'
  119. })
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss">
  125. page{
  126. height: 100%;
  127. }
  128. .content{
  129. height: 100%;
  130. display: flex;
  131. flex-direction: column;
  132. justify-content: space-between;
  133. .inner{
  134. flex: 1;
  135. padding: 20upx 20upx 160upx;
  136. .top{
  137. padding: 0upx 20upx 20upx;
  138. text-align: right;
  139. .del{
  140. font-size: 28upx;
  141. font-family: PingFang SC;
  142. color: #999999;
  143. }
  144. }
  145. .address-item{
  146. background: #FFFFFF;
  147. border-radius: 16upx;
  148. padding: 46upx 40upx 50upx 24upx;
  149. display: flex;
  150. align-items: center;
  151. justify-content: space-between;
  152. margin-bottom: 20upx;
  153. .info{
  154. width: 75%;
  155. .title{
  156. font-size: 30upx;
  157. font-family: PingFang SC;
  158. font-weight: bold;
  159. color: #111111;
  160. line-height: 42upx;
  161. word-break: break-all;
  162. .tag{
  163. padding: 0 6upx;
  164. height: 32upx;
  165. line-height: 32upx;
  166. font-size: 22upx;
  167. font-family: PingFang SC;
  168. font-weight: 500;
  169. color: #FFFFFF;
  170. background: #2583EB;
  171. border-radius: 4upx;
  172. float: left;
  173. margin-right: 10upx;
  174. margin-top: 5upx;
  175. }
  176. }
  177. .name-phone{
  178. margin-top: 30upx;
  179. display: flex;
  180. align-items: center;
  181. .text{
  182. font-size: 26upx;
  183. font-family: PingFang SC;
  184. font-weight: 500;
  185. color: #999999;
  186. margin-right: 22upx;
  187. &:last-child{
  188. margin-right: 0;
  189. }
  190. }
  191. }
  192. }
  193. .operat-box{
  194. display: flex;
  195. align-items: center;
  196. image{
  197. padding: 15rpx;
  198. width: 30upx;
  199. height: 30upx;
  200. margin-left: 10upx;
  201. &:first-child{
  202. margin-left: 0;
  203. }
  204. }
  205. }
  206. }
  207. }
  208. .btn-box{
  209. z-index: 9999;
  210. width: 100%;
  211. padding: 30upx;
  212. position: fixed;
  213. bottom: 0;
  214. left: 0;
  215. box-sizing: border-box;
  216. background: #FFFFFF;
  217. .sub-btn{
  218. height: 88upx;
  219. line-height: 88upx;
  220. text-align: center;
  221. font-size: 30upx;
  222. font-family: PingFang SC;
  223. font-weight: bold;
  224. color: #FFFFFF;
  225. background: #2583EB;
  226. border-radius: 44upx;
  227. }
  228. }
  229. }
  230. </style>