password.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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.addressDetail}}</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/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. alertText:'确定要删除该地址?',
  61. userID:'',
  62. pageNum:1,
  63. pageSize:10,
  64. addressList: [],
  65. hasNextPage:false,
  66. allowDataStatus:true,
  67. isShowDelModal:false,
  68. wrapperHeight:'100%',
  69. scrollHeight:'',
  70. deleteAddressId:'',
  71. currPage:'',//当前页面
  72. prevPage:''//上一个页面
  73. }
  74. },
  75. onLoad(option){
  76. if(option.type=='select'){this.isSelect = true;}
  77. this.setScrollHeight();
  78. },
  79. onReachBottom() {
  80. if(this.isLoadMore) {
  81. this.initAddressList();
  82. }
  83. },
  84. methods: {
  85. setScrollHeight() {
  86. // 窗口高度 - 底部距离
  87. setTimeout(()=> {
  88. const query = wx.createSelectorQuery().in(this);
  89. query.selectAll('.add-btn').boundingClientRect();
  90. query.exec(res => {
  91. if(res[0][0]){
  92. let winHeight = this.$api.getWindowHeight(),
  93. eleTop = res[0][0].top - 1;
  94. this.scrollHeight = eleTop;
  95. }
  96. })
  97. }, 500)
  98. },
  99. initAddressList(){
  100. this.$api.getStorage().then((resolve) =>{
  101. this.userID = resolve.userID
  102. this.$api.get('/personal/findAddress',{index:this.pageNum,pageSize:this.pageSize,userID:this.userID},
  103. response => {
  104. if(response.results == ''){
  105. this.isEmpty = true
  106. }else{
  107. this.isEmpty = false
  108. let results =[];
  109. results = response.results;
  110. this.addressList = this.addressList.concat(results);
  111. this.pageNum = response.index +1;
  112. if(this.pageNum === response.totalPage + 1 ){
  113. this.isLoadMore = false;
  114. } else {
  115. this.isLoadMore = true;
  116. }
  117. }
  118. }
  119. )
  120. })
  121. },
  122. //选择地址
  123. checkAddress(item){
  124. //是否需要返回地址(从订单确认页跳过来选收货地址)
  125. if(!this.isSelect){return ;}
  126. uni.setStorageSync('selectAddress',item)
  127. var pages = getCurrentPages();
  128. var prevPage = pages[pages.length - 2]; //上一个页面
  129. prevPage.setData({select:'select'})
  130. uni.navigateBack();
  131. },
  132. addAddress(type,item){
  133. uni.navigateTo({
  134. url: `/pages/user/address/addressManage?type=${type}&data=${JSON.stringify(item)}`
  135. })
  136. },
  137. //删除收货地址
  138. deleteAddress(id){
  139. this.isShowDelModal = true;
  140. this.deleteAddressId =id;
  141. },
  142. confirmDetele(){
  143. authorize.getCode('weixin').then(wechatcode =>{
  144. this.$api.get('/personal/delete?code='+`${wechatcode}`,{addressID:this.deleteAddressId,userOrganizeID:this.userOrganizeID},
  145. response => {
  146. if(response.code==1){
  147. uni.showToast({
  148. icon: 'none',
  149. title: response.msg,
  150. duration: 2000
  151. })
  152. this.isShowDelModal = false;
  153. this.pageNum = 1;
  154. this.addressList = [];
  155. this.initAddressList();
  156. }else{
  157. this.$util.msg(response.msg,2000);
  158. this.isShowDelModal = false;
  159. setTimeout(function(){
  160. uni.switchTab({
  161. url:'/pages/tabBar/home/home'
  162. })
  163. },1000)
  164. }
  165. }
  166. )
  167. })
  168. },
  169. },
  170. onShow() {
  171. this.pageNum = 1;
  172. this.addressList = [];
  173. this.initAddressList();
  174. var pages = getCurrentPages();
  175. var prevPage = pages[pages.length - 2]; //上一个页面
  176. // prevPage.setData({select:''})
  177. }
  178. }
  179. </script>
  180. <style lang='scss'>
  181. page {
  182. height: auto;
  183. }
  184. page,.container{
  185. /* padding-bottom: 120upx; */
  186. background: #F7F7F7;
  187. border-top: 1px solid #EBEBEB;
  188. }
  189. .container{
  190. position: relative;
  191. }
  192. .list{
  193. display: flex;
  194. align-items: center;
  195. width: 702rpx;
  196. height: auto;
  197. padding: 24rpx;
  198. background: #FFFFFF;
  199. position: relative;
  200. border-bottom: 1px solid #EBEBEB;
  201. }
  202. .wrapper{
  203. display: flex;
  204. flex-direction: column;
  205. flex: 1;
  206. }
  207. .u-box.b-b{
  208. }
  209. .u-box.b-b{
  210. margin-bottom:24rpx;
  211. }
  212. .u-box.b-t{
  213. margin-bottom:0;
  214. }
  215. .u-box{
  216. display: flex;
  217. align-items: center;
  218. font-size: $font-size-28;
  219. color: $text-color;
  220. line-height: 40rpx;
  221. margin-bottom: 12rpx;
  222. .name{
  223. margin-right: 40rpx;
  224. font-weight: bold;
  225. }
  226. .mobile{
  227. font-weight: bold;
  228. }
  229. .tag-left{
  230. flex: 6;
  231. .tag{
  232. width: 120rpx;
  233. height: 40rpx;
  234. background: $color-system;
  235. border-radius: 20rpx;
  236. font-size: $font-size-24;
  237. color: #FFFFFF;
  238. line-height: 40rpx;
  239. text-align: center;
  240. padding: 0 6rpx;
  241. }
  242. }
  243. .tag-right{
  244. flex: 4;
  245. display: flex;
  246. text-align: right;
  247. .t-b{
  248. flex: 1;
  249. line-height: 40rpx;
  250. .txt{
  251. font-size: $font-size-24;
  252. color: $text-color;
  253. line-height: 40rpx;
  254. }
  255. }
  256. .icon-shanchu{
  257. color:#FF2A2A ;
  258. margin-right: 8rpx;
  259. }
  260. .icon-bianji{
  261. color: #2A7AFF;
  262. margin-right: 8rpx;
  263. }
  264. }
  265. .address{
  266. font-size: $font-size-28;
  267. color: $text-color;
  268. line-height: 40rpx;
  269. -o-text-overflow: ellipsis;
  270. text-overflow: ellipsis;
  271. display: -webkit-box;
  272. word-break: break-all;
  273. -webkit-box-orient: vertical;
  274. -webkit-line-clamp: 2;
  275. overflow: hidden;
  276. }
  277. }
  278. .add-btn{
  279. position: fixed;
  280. left: 24rpx;
  281. right: 24rpx;
  282. bottom: 34rpx;
  283. z-index: 95;
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. width: 702rpx;
  288. height: 88rpx;
  289. font-size: $font-size-28;
  290. line-height: 88rpx;
  291. color: #FFFFFF;
  292. text-align: center;
  293. background: $btn-confirm;
  294. border-radius: 14rpx;
  295. }
  296. .adds-btn{
  297. width: 702rpx;
  298. height: 88rpx;
  299. font-size: 28rpx;
  300. line-height: 88rpx;
  301. color: #FFFFFF;
  302. margin: 0 auto;
  303. text-align: center;
  304. background: #000000;
  305. border-radius: 14rpx;
  306. }
  307. </style>