address.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <view class="container clearfix">
  3. <view v-if="isEmpty" class="empty-container">
  4. <image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AFmO1AAGxLZjSeDg040.png" mode="aspectFit"></image>
  5. <view class="txt">您还没有收货地址</view>
  6. <view class="txt">点击底部按钮添加收货地址吧~~</view>
  7. <view class="login-btn" @click="addAddress('add')">添加新地址</view>
  8. </view>
  9. <view v-else class="address-list" :style="{'height': scrollHeight + 'px'}">
  10. <scroll-view scroll-y="true" :style="{'height': scrollHeight + 'px'}">
  11. <view class="list" v-for="(item, index) in addressList" :key="index" @click="checkAddress(item)">
  12. <view class="wrapper">
  13. <view class="u-box">
  14. <text class="name">{{item.shouHuoRen}}</text>
  15. <text class="mobile">{{item.mobile}}</text>
  16. </view>
  17. <view class="u-box b-b">
  18. <text class="address">收货地址:{{item.province}}{{item.city}}{{item.town}}{{item.address}}</text>
  19. </view>
  20. <view class="u-box b-t">
  21. <view v-if="item.defaultFlag == 1" class="tag-left">
  22. <view class="tag">默认地址</view>
  23. </view>
  24. <view v-else class="tag-left"></view>
  25. <view class="tag-right">
  26. <view class="t-b" @click.stop="deleteAddress(item.addressID)">
  27. <text class="iconfont icon-shanchu"></text>
  28. <text class="txt">删除</text>
  29. </view>
  30. <view class="t-b" @click.stop="addAddress('edit',item)">
  31. <text class="iconfont icon-bianji"></text>
  32. <text class="txt">编辑</text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </scroll-view>
  39. <view class="add-btn" @click="addAddress('add')">添加新地址</view>
  40. </view>
  41. <!-- 删除弹窗 -->
  42. <model-alert v-if="isShowDelModal"
  43. :alertText='alertText'
  44. @btnConfirm ='confirmDetele'>
  45. </model-alert>
  46. </view>
  47. </template>
  48. <script>
  49. import authorize from '@/common/config/authorize.js'
  50. import modelAlert from '@/components/cm-module/modelAlert/modelAlert.vue'
  51. export default {
  52. components:{
  53. modelAlert
  54. },
  55. data() {
  56. return {
  57. isSelect:false,
  58. isEmpty:false,
  59. isLoadMore:false,
  60. userID:'',
  61. pageNum:1,
  62. pageSize:10,
  63. addressList: [],
  64. hasNextPage:false,
  65. allowDataStatus:true,
  66. wrapperHeight:'100%',
  67. scrollHeight:'',
  68. currPage:'',//当前页面
  69. prevPage:''//上一个页面
  70. }
  71. },
  72. onLoad(option){
  73. if(option.type=='select'){this.isSelect = true;}
  74. this.setScrollHeight();
  75. },
  76. onReachBottom() {
  77. if(this.isLoadMore) {
  78. this.initAddressList();
  79. }
  80. },
  81. methods: {
  82. setScrollHeight() { // 窗口高度 - 底部距离
  83. setTimeout(()=> {
  84. const query = wx.createSelectorQuery().in(this);
  85. query.selectAll('.add-btn').boundingClientRect();
  86. query.exec(res => {
  87. if(res[0][0]){
  88. let winHeight = this.$api.getWindowHeight(),
  89. eleTop = res[0][0].top - 1;
  90. this.scrollHeight = eleTop;
  91. }
  92. })
  93. }, 500)
  94. },
  95. initAddressList(){
  96. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  97. this.userID = resolve.userID
  98. let params = {pageNum:this.pageNum,pageSize:this.pageSize,userID:this.userID}
  99. this.UserService.QueryAddressList(params).then(response =>{
  100. if(response.data.results == ''){
  101. this.isEmpty = true
  102. }else{
  103. this.isEmpty = false
  104. let results =[];
  105. results = response.data.results;
  106. this.addressList = this.addressList.concat(results);
  107. this.pageNum = response.index +1;
  108. if(this.pageNum === response.totalPage + 1 ){
  109. this.isLoadMore = false;
  110. } else {
  111. this.isLoadMore = true;
  112. }
  113. }
  114. }).catch(error =>{
  115. this.$util.msg(error.msg,2000)
  116. })
  117. })
  118. },
  119. //选择地址
  120. checkAddress(item){
  121. //是否需要返回地址(从订单确认页跳过来选收货地址)
  122. if(!this.isSelect){return ;}
  123. uni.setStorageSync('selectAddress',item)
  124. var pages = getCurrentPages();
  125. var prevPage = pages[pages.length - 2]; //上一个页面
  126. prevPage.setData({select:'select'})
  127. uni.navigateBack();
  128. },
  129. addAddress(type,item){
  130. uni.navigateTo({
  131. url: `/seller/pages/address/addressManage?type=${type}&data=${JSON.stringify(item)}`
  132. })
  133. },
  134. //删除收货地址
  135. deleteAddress(id){
  136. this.$util.modal('','确定要删除该地址?','确定','取消',true,() =>{
  137. this.UserService.DeleteNewAddress({addressID:id,userID:this.userID}).then(response =>{
  138. this.$util.msg('删除成功',2000,true,'success')
  139. setTimeout(() =>{
  140. this.pageNum = 1;
  141. this.addressList = [];
  142. this.initAddressList();
  143. },2000)
  144. }).catch(error =>{
  145. this.$util.msg(error.msg,2000);
  146. setTimeout(function(){
  147. uni.switchTab({
  148. url:'/seller/pages/home/home'
  149. })
  150. },1000)
  151. })
  152. })
  153. }
  154. },
  155. onShow() {
  156. this.$api.getStorage().then((resolve) =>{
  157. this.userID = resolve.userID
  158. this.pageNum = 1;
  159. this.addressList = [];
  160. this.initAddressList();
  161. var pages = getCurrentPages();
  162. var prevPage = pages[pages.length - 2]; //上一个页面
  163. // prevPage.setData({select:''})
  164. })
  165. }
  166. }
  167. </script>
  168. <style lang='scss'>
  169. page {
  170. height: auto;
  171. }
  172. page,.container{
  173. /* padding-bottom: 120upx; */
  174. background: #F7F7F7;
  175. border-top: 1px solid #EBEBEB;
  176. }
  177. .container{
  178. position: relative;
  179. }
  180. .list{
  181. display: flex;
  182. align-items: center;
  183. width: 702rpx;
  184. height: auto;
  185. padding: 24rpx;
  186. background: #FFFFFF;
  187. position: relative;
  188. border-bottom: 1px solid #EBEBEB;
  189. }
  190. .wrapper{
  191. display: flex;
  192. flex-direction: column;
  193. flex: 1;
  194. }
  195. .u-box.b-b{
  196. }
  197. .u-box.b-b{
  198. margin-bottom:24rpx;
  199. }
  200. .u-box.b-t{
  201. margin-bottom:0;
  202. }
  203. .u-box{
  204. display: flex;
  205. align-items: center;
  206. font-size: $font-size-28;
  207. color: $text-color;
  208. line-height: 40rpx;
  209. margin-bottom: 12rpx;
  210. .name{
  211. margin-right: 40rpx;
  212. font-weight: bold;
  213. }
  214. .mobile{
  215. font-weight: bold;
  216. }
  217. .tag-left{
  218. flex: 6;
  219. .tag{
  220. width: 120rpx;
  221. height: 40rpx;
  222. background: $color-system;
  223. border-radius: 20rpx;
  224. font-size: $font-size-24;
  225. color: #FFFFFF;
  226. line-height: 40rpx;
  227. text-align: center;
  228. padding: 0 6rpx;
  229. }
  230. }
  231. .tag-right{
  232. flex: 4;
  233. display: flex;
  234. text-align: right;
  235. .t-b{
  236. flex: 1;
  237. line-height: 40rpx;
  238. .txt{
  239. font-size: $font-size-24;
  240. color: $text-color;
  241. line-height: 40rpx;
  242. }
  243. }
  244. .icon-shanchu{
  245. color:#FF2A2A ;
  246. margin-right: 8rpx;
  247. }
  248. .icon-bianji{
  249. color: #2A7AFF;
  250. margin-right: 8rpx;
  251. }
  252. }
  253. .address{
  254. font-size: $font-size-28;
  255. color: $text-color;
  256. line-height: 40rpx;
  257. -o-text-overflow: ellipsis;
  258. text-overflow: ellipsis;
  259. display: -webkit-box;
  260. word-break: break-all;
  261. -webkit-box-orient: vertical;
  262. -webkit-line-clamp: 2;
  263. overflow: hidden;
  264. }
  265. }
  266. .add-btn{
  267. position: fixed;
  268. left: 24rpx;
  269. right: 24rpx;
  270. bottom: 34rpx;
  271. z-index: 95;
  272. display: flex;
  273. align-items: center;
  274. justify-content: center;
  275. width: 702rpx;
  276. height: 88rpx;
  277. font-size: $font-size-28;
  278. line-height: 88rpx;
  279. color: #FFFFFF;
  280. text-align: center;
  281. background: $btn-confirm;
  282. border-radius: 45rpx;
  283. }
  284. .adds-btn{
  285. width: 702rpx;
  286. height: 88rpx;
  287. font-size: 28rpx;
  288. line-height: 88rpx;
  289. color: #FFFFFF;
  290. margin: 0 auto;
  291. text-align: center;
  292. background: #000000;
  293. border-radius: 14rpx;
  294. }
  295. </style>