address.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view class="tui-safe-area">
  3. <view class="tui-address">
  4. <block v-for="(item,index) in addressList" :key="index">
  5. <tui-list-cell padding="0">
  6. <view class="tui-address-flex">
  7. <view @tap="selectTap" :data-id="item.id" class="tui-address-left">
  8. <view class="tui-address-main">
  9. <view class="tui-address-name tui-ellipsis">{{item.name}}</view>
  10. <view class="tui-address-tel">{{item.telephone}}</view>
  11. </view>
  12. <view class="tui-address-detail">
  13. <view :style="'background:'+ pagestyleconfig.appstylecolor" class="tui-address-label" v-if="item.isDefault===1">默认</view>
  14. <!--<view class="tui-address-label">{{["公司","住宅","其它"][index]}}</view>-->
  15. <text>{{item.address_detail}}{{item.address}}</text>
  16. </view>
  17. </view>
  18. <view v-if="item.is_bindingaddress!=1" class="tui-address-imgbox" @tap="editAddess" :data-id="item.id">
  19. <image class="tui-address-img" src="/static/images/mall/my/icon_addr_edit.png" />
  20. </view>
  21. </view>
  22. </tui-list-cell>
  23. </block>
  24. </view>
  25. <!-- 新增地址 -->
  26. <view class="tui-address-new" v-if="is_bindingaddress==0 || addressList.length==0">
  27. <button class="addressbutt" @click="addAddess" :style="'background:'+ pagestyleconfig.appstylecolor">+ 新增地址</button>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. addressList: [],
  36. pagestyleconfig: [],
  37. is_bindingaddress: 0,
  38. atype: '',
  39. }
  40. },
  41. onLoad: function(options) {
  42. let _this = this;
  43. this.atype = options.atype;
  44. _this.$request.post('config', {
  45. mo: 'pagestyle'
  46. }).then(res => {
  47. if (res.errno == 0) {
  48. _this.pagestyleconfig = res.data
  49. }
  50. });
  51. },
  52. onShow: function() {
  53. this.initShippingAddress();
  54. },
  55. methods: {
  56. selectTap: function(e) {
  57. var id = e.currentTarget.dataset.id;
  58. if (this.atype == 'take') {
  59. uni.setStorageSync('take_address_id', id);
  60. uni.navigateBack({});
  61. } else {
  62. uni.setStorageSync('address_id', id);
  63. this.$request.post('address.setdefault', {
  64. id: id
  65. }).then(res => {
  66. uni.navigateBack({});
  67. })
  68. }
  69. },
  70. addAddess: function() {
  71. wx.navigateTo({
  72. url: "/pagesA/my/address/editAddress?is_bindingaddress=" + this.is_bindingaddress
  73. })
  74. },
  75. editAddess: function(e) {
  76. wx.navigateTo({
  77. url: "/pagesA/my/address/editAddress?id=" + e.currentTarget.dataset.id
  78. })
  79. },
  80. initShippingAddress: function() {
  81. var _this = this;
  82. _this.$request.get('address.list', {
  83. samkey: (new Date()).valueOf()
  84. }).then(res => {
  85. if (res.errno == 0) {
  86. _this.addressList = res.data;
  87. _this.is_bindingaddress = res.is_bindingaddress;
  88. } else if (res.errno == 700) {
  89. _this.addressList = null;
  90. }
  91. })
  92. }
  93. },
  94. /**
  95. * 页面相关事件处理函数--监听用户下拉动作
  96. */
  97. onPullDownRefresh: function() {
  98. setTimeout(() => {
  99. uni.stopPullDownRefresh()
  100. }, 200);
  101. },
  102. }
  103. </script>
  104. <style>
  105. .tui-address {
  106. width: 100%;
  107. padding-top: 20rpx;
  108. padding-bottom: 160rpx;
  109. }
  110. .tui-address-flex {
  111. display: flex;
  112. justify-content: space-between;
  113. align-items: center;
  114. }
  115. .tui-address-main {
  116. width: 600rpx;
  117. height: 70rpx;
  118. display: flex;
  119. font-size: 30rpx;
  120. line-height: 86rpx;
  121. padding-left: 30rpx;
  122. }
  123. .tui-address-name {
  124. width: 120rpx;
  125. height: 60rpx;
  126. }
  127. .tui-address-tel {
  128. margin-left: 12rpx;
  129. }
  130. .tui-address-detail {
  131. font-size: 24rpx;
  132. word-break: break-all;
  133. padding-bottom: 25rpx;
  134. padding-left: 25rpx;
  135. padding-right: 120rpx;
  136. }
  137. .tui-address-label {
  138. padding: 5rpx 8rpx;
  139. flex-shrink: 0;
  140. border-radius: 6rpx;
  141. color: #fff;
  142. display: inline-flex;
  143. align-items: center;
  144. justify-content: center;
  145. font-size: 25rpx;
  146. line-height: 25rpx;
  147. transform: scale(0.8);
  148. transform-origin: center center;
  149. margin-right: 6rpx;
  150. }
  151. .tui-address-imgbox {
  152. width: 80rpx;
  153. height: 100rpx;
  154. position: absolute;
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. right: 10rpx;
  159. }
  160. .tui-address-img {
  161. width: 36rpx;
  162. height: 36rpx;
  163. }
  164. .tui-address-new {
  165. width: 100%;
  166. position: fixed;
  167. left: 0;
  168. bottom: 0;
  169. z-index: 999;
  170. padding: 20rpx 25rpx 30rpx;
  171. box-sizing: border-box;
  172. background: #fafafa;
  173. }
  174. .tui-safe-area {
  175. padding-bottom: env(safe-area-inset-bottom);
  176. }
  177. .addressbutt {
  178. height: 88rpx;
  179. line-height: 88rpx;
  180. font-size: 28rpx;
  181. border-radius: 50rpx;
  182. color: #ffffff;
  183. align-items: center;
  184. }
  185. </style>