You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

237 lines
6.3 KiB

6 months ago
  1. <template>
  2. <view>
  3. <view class="content">
  4. <view class="list">
  5. <view class="row" @tap="select(row)" v-if="address!=''">
  6. <view class="left">
  7. <view class="head">
  8. {{address.header}}
  9. </view>
  10. </view>
  11. <view class="center">
  12. <view class="name-tel">
  13. <view class="name">{{address.name}}</view>
  14. <view class="tel">{{address.tel}}</view>
  15. <!--<view class="default" v-if="1"默认</view>-->
  16. </view>
  17. <view class="address">
  18. {{address.address}} {{address.detail}}
  19. </view>
  20. </view>
  21. <view class="right">
  22. <view class="icon bianji" @tap.stop="edit(address)">
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="add">
  29. <view class="btn" @tap="add" v-if="address==''">
  30. <view class="icon tianjia"></view>新增地址
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. isSelect:false,
  40. addressList:[
  41. {id:1,name:"大黑哥",head:"大",tel:"18816881688",address:{region:{"label":"广东省-深圳市-福田区","value":[18,2,1],"cityCode":"440304"},detailed:'深南大道1111号无名摩登大厦6楼A2'},isDefault:true},
  42. {id:2,name:"大黑哥",head:"大",tel:"15812341234",address:{region:{"label":"广东省-深圳市-福田区","value":[18,2,1],"cityCode":"440304"},detailed:'深北小道2222号有名公寓502'},isDefault:false},
  43. {id:3,name:"老大哥",head:"老",tel:"18155467897",address:{region:{"label":"广东省-深圳市-福田区","value":[18,2,1],"cityCode":"440304"},detailed:'深南大道1111号无名摩登大厦6楼A2'},isDefault:false},
  44. {id:4,name:"王小妹",head:"王",tel:"13425654895",address:{region:{"label":"广东省-深圳市-福田区","value":[18,2,1],"cityCode":"440304"},detailed:'深南大道1111号无名摩登大厦6楼A2'},isDefault:false},
  45. ],
  46. address:[]
  47. };
  48. },
  49. onShow() {
  50. uni.getStorage({
  51. key:'delAddress',
  52. success: (e) => {
  53. let len = this.addressList.length;
  54. if(e.data.hasOwnProperty('id')){
  55. for(let i=0;i<len;i++){
  56. if(this.addressList[i].id==e.data.id){
  57. this.addressList.splice(i,1);
  58. break;
  59. }
  60. }
  61. }
  62. uni.removeStorage({
  63. key:'delAddress'
  64. })
  65. }
  66. })
  67. uni.getStorage({
  68. key:'userinfo',
  69. success: (e) => {
  70. console.log(e.data)
  71. //判断地址不能为空
  72. if(e.data.address!=''){
  73. this.address=e.data;
  74. this.address.header=e.data.name.substr(0,1)
  75. }
  76. //this.address=JSON.parse(e.data)
  77. console.log(this.address)
  78. //this.address.header=e.data.name.substr(0,1)
  79. }
  80. })
  81. },
  82. onLoad(e) {
  83. if(e.type=='select'){
  84. this.isSelect = true;
  85. }
  86. },
  87. methods:{
  88. edit(row){
  89. console.log(row);
  90. // return;
  91. uni.setStorage({
  92. key:'address',
  93. data:row,
  94. success() {
  95. uni.navigateTo({
  96. url:"edit/edit?type=edit"
  97. })
  98. }
  99. });
  100. },
  101. add(){
  102. uni.navigateTo({
  103. url:"edit/edit?type=add"
  104. })
  105. },
  106. select(row){
  107. //是否需要返回地址(从订单确认页跳过来选收货地址)
  108. if(!this.isSelect){
  109. return ;
  110. }
  111. uni.setStorage({
  112. key:'selectAddress',
  113. data:row,
  114. success() {
  115. uni.navigateBack();
  116. }
  117. })
  118. }
  119. }
  120. }
  121. </script>
  122. <style lang="scss">
  123. view{
  124. display: flex;
  125. }
  126. @font-face {font-family:"HMfont-home";src:url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAMIAAsAAAAABvwAAAK8AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDBgqBSIFAATYCJAMMCwgABCAFhG0HVBskBsiusClj9ljNiEIaBdizs389YOCARVDt99mzu+8dMMpzQEn5KEAZRez+yRDbSDIixkYo1tF/+vv5OxYJFk2VghXWbbzzPn8D/OMG3vvXGTU90ZFhOrNJROZwCRGjj/Iry36wAbfSxBsuNGggeG9sMbJKDd7xg8vpr4ACmWdZLnMtGxMwwUD3wCiywi3oDWMXuITzBNpNc4BP3j5/Q1thTQvE1SQiaOd8isKSrUJds7aIVyqt6XECAF6Gj49/sBcUSZVZc09duQng/CfPcXTVrIs+gj+fBWwTGZsghbhcGzurJhgZ1S6rt2fXipDmCv5PyNMltf2HRxJEzSrsBKtIk9wU32WS+E1w14UZ1HFiG+QkJg3ODWmyn5/20eOvTz5LnR6l8aWDT5Sn3wLtYlfNe7RIik/fN961C3Vftf6YZLr5ZMcjU/LExqD9u3LzvKE8KQtBGAp9ilm1XbAK2m83TdlozEvQ0Zbrh8HBMrKDB03MjRwHaJKP2f5jf+NfDvML4f+tHQX8+EJvkwL1z9Mqwfi/kd+zq+hCS5+LynN5piObGRlNaNedmrJc/R7jVUO3agmtOT7zJy32WkjWahGihbQJlQ5bklpT7ENotyG3ucOAjpoobVi3BxB6HSDp9h2yXne0kDSoDPtBrTdQaHc61D07LEezm1Im4wBLc2z6UoaO0bpR8SdHLifNCkPKL+s4CaLX5Skm77hknWNBdxLt9SzEmkqBWXAZ57lgSyVl37YaZqMzt7tWd6OtshTQdYJixLAAKplDTT5RCv3Bplu6/ycWcXJEW+pqrL+YGkuGR14unh7onazsVXcv13RNRPb0mBCqUaKAssDCcjsmUKt+VIr5zJbGiMjIGTfqV+sr21pfUXxALmvCmpMjRY5i9G5CZepynIyYZOr+sksyR2W0UHLiChIrRmXfA0E') format('woff2');}
  127. .icon {
  128. font-family:"HMfont-home" !important;
  129. font-size:60upx;
  130. font-style:normal;
  131. color:#000000;
  132. &.bianji {
  133. &:before{content:"\e61b";}
  134. }
  135. &.tianjia {
  136. &:before{content:"\e81a";}
  137. }
  138. }
  139. .add{
  140. position: fixed;
  141. bottom: 0;
  142. width: 100%;
  143. height: 120upx;
  144. justify-content: center;
  145. align-items: center;
  146. .btn{
  147. box-shadow: 0upx 5upx 10upx rgba(0,0,0,0.4);
  148. width: 70%;
  149. height: 80upx;
  150. border-radius: 80upx;
  151. background-color: #f06c7a;
  152. color: #fff;
  153. justify-content: center;
  154. align-items: center;
  155. .icon{
  156. height: 80upx;
  157. color: #fff;
  158. font-size: 30upx;
  159. justify-content: center;
  160. align-items: center;
  161. }
  162. font-size: 30upx;
  163. }
  164. }
  165. .list{
  166. flex-wrap: wrap;
  167. .row{
  168. width: 96%;
  169. padding: 20upx 2%;
  170. .left{
  171. width: 90upx;
  172. flex-shrink: 0;
  173. align-items: center;
  174. .head{
  175. width: 70upx;
  176. height: 70upx;
  177. background:linear-gradient(to right,#ccc,#aaa);
  178. color: #fff;
  179. justify-content: center;
  180. align-items: center;
  181. border-radius: 60upx;
  182. font-size: 35upx;
  183. }
  184. }
  185. .center{
  186. width: 100%;
  187. flex-wrap: wrap;
  188. .name-tel{
  189. width: 100%;
  190. align-items: baseline;
  191. .name{
  192. font-size: 34upx;
  193. }
  194. .tel{
  195. margin-left: 30upx;
  196. font-size: 24upx;
  197. color: #777;
  198. }
  199. .default{
  200. font-size: 22upx;
  201. background-color: #f06c7a;
  202. color: #fff;
  203. padding: 0 18upx;
  204. border-radius: 24upx;
  205. margin-left: 20upx;
  206. }
  207. }
  208. .address{
  209. width: 100%;
  210. font-size: 24upx;
  211. align-items: baseline;
  212. color: #777;
  213. }
  214. }
  215. .right{
  216. flex-shrink: 0;
  217. align-items: center;
  218. margin-left: 20upx;
  219. .icon{
  220. justify-content: center;
  221. align-items: center;
  222. width: 80upx;
  223. height: 60upx;
  224. border-left: solid 1upx #aaa;
  225. font-size: 40upx;
  226. color: #777;
  227. }
  228. }
  229. }
  230. }
  231. </style>