AddressList.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <seller-base :show="false">
  3. <view class="div distributor-address-list">
  4. <view class="div common-header-wrap">
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="发货地址" class="common-header" left-icon="back" @clickLeft="goBack">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view class="div pb-30" v-if="address_list.length>0">
  14. <view class="div item" v-for="item in address_list" :key="item.daddress_id">
  15. <view class="div container">
  16. <view class="div top-wrapper">
  17. <view class="div selected-wrapper">
  18. <view class="div line">
  19. <text class="i icon iconfont">&#xe6d3;</text>
  20. <view class="div line-content">
  21. <view class="div title-wrapper">
  22. <label class="title">{{item.seller_name}}</label>
  23. <label class="title" style="margin-left:1rem;">{{item.daddress_telphone}}</label>
  24. </view>
  25. <view class="div desc address-text">{{item.area_info}}{{item.daddress_detail}}</view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="div bottom-line"></view>
  30. </view>
  31. <view class="div bottom-wrapper">
  32. <view class="div bottom-left-wrapper" @click="onDefault(item)">
  33. <label class="subtitle">
  34. <text v-if="item.daddress_isdefault == 1" class="i iconfont">&#xe69d;</text><text v-else class="i iconfont">&#xe69e;</text>默认地址
  35. </label>
  36. </view>
  37. <view class="div bottom-right-wrapper">
  38. <view class="div edit-wrapper" @click="onEdit(item.daddress_id)">
  39. <view class="div common-btn btn-2 mr-5">编辑</view>
  40. </view>
  41. <view class="div edit-wrapper delete-wrapper" @click="onDelete(item.daddress_id)">
  42. <view class="div common-btn btn-1">删除</view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="div" v-else>
  50. <empty-record></empty-record>
  51. </view>
  52. <view class='common-add-btn-wrapper'><view class="div common-btn common-add-btn" @click="goAdd">新增</view></view>
  53. </view>
  54. </seller-base>
  55. </template>
  56. <script>
  57. import {getFontSize} from '@/util/common'
  58. import TitleHeader from '../../TitleHeader'
  59. import { urlencode } from '@/util/common'
  60. import SellerBase from '../SellerBase'
  61. import EmptyRecord from '../../EmptyRecord'
  62. import { getAddressList, delAddress, editAddress } from '../../../api/sellerAddress'
  63. export default {
  64. components:{
  65. TitleHeader,
  66. SellerBase,
  67. EmptyRecord
  68. },
  69. name: 'SellerAddressList',
  70. computed:{
  71. fontSize(){
  72. return getFontSize()
  73. },
  74. },
  75. data(){
  76. return {
  77. navHeight: 0,
  78. address_list: []
  79. }
  80. },
  81. onShow: function () {
  82. this.getAddressList()
  83. },
  84. mounted(){
  85. // #ifdef MP-WEIXIN
  86. this.navHeight = uni.getMenuButtonBoundingClientRect().height
  87. // #endif
  88. },
  89. methods: {
  90. goBack () {
  91. uni.navigateBack({delta:1})
  92. },
  93. goAdd () {
  94. uni.navigateTo({url:'/pages/seller/address/AddressForm'+'?'+urlencode({ action: 'add' })})
  95. },
  96. onDefault (address_info) {
  97. address_info.daddress_isdefault = 1
  98. editAddress(address_info, address_info.daddress_id).then(
  99. (response) => {
  100. uni.hideLoading()
  101. this.getAddressList()
  102. }, (error) => {
  103. uni.hideLoading()
  104. uni.showToast({icon:'none',title: error.message})
  105. })
  106. },
  107. onEdit (addressId) {
  108. uni.navigateTo({url:'/pages/seller/address/AddressForm'+'?'+urlencode({ address_id: addressId })})
  109. },
  110. onDelete (addressId) {
  111. uni.showLoading({ title: '加载中' })
  112. delAddress(addressId).then(
  113. (response) => {
  114. this.getAddressList()
  115. uni.hideLoading()
  116. }, (error) => {
  117. uni.hideLoading()
  118. uni.showToast({icon:'none',title: error.message})
  119. })
  120. },
  121. getAddressList () {
  122. getAddressList().then(res => {
  123. this.address_list = res.result.address_list
  124. }).catch(function (error) {
  125. uni.showToast({icon:'none',title: error.message})
  126. })
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. .distributor-address-list {
  133. .common-header{
  134. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  135. }
  136. .line{display: flex;
  137. .line-content{flex:1}
  138. }
  139. .item{margin-bottom:$modelSpace}
  140. .container{background: #fff;padding:0 $pageSpace}
  141. .btn-1{border:1px solid $primaryColor;color:$primaryColor;min-width: 2rem}
  142. .btn-2{border:1px solid #333;color:#333;min-width: 2rem}
  143. .top-wrapper {
  144. position: relative;
  145. flex: 1;
  146. display: flex;
  147. flex-direction: row;
  148. justify-content: flex-start;
  149. align-items: center;
  150. background-color: #fff;
  151. }
  152. .title-wrapper {
  153. height: 1rem;
  154. display: flex;
  155. flex-direction: row;
  156. justify-content: flex-start;
  157. align-items: center;
  158. }
  159. .icon {
  160. font-size:$h1;
  161. margin-right: .2rem;
  162. color:$primaryColor
  163. }
  164. .title {
  165. font-size:$h3;
  166. color: #333;
  167. font-weight: 700;
  168. }
  169. .default {
  170. width: 1.4rem;
  171. margin-left: 0.5rem;
  172. margin-right: 0.5rem;
  173. border: 1px solid $primaryColor;
  174. color: $primaryColor;
  175. font-size:$h6;
  176. text-align: center;
  177. border-radius: 0.1rem;
  178. }
  179. .desc {
  180. color: $descTextColor;
  181. font-size:$subFontSize;
  182. }
  183. .address-text {
  184. margin-top: .3rem;
  185. font-weight: normal;
  186. }
  187. .selected-wrapper{
  188. padding:1rem 0;
  189. }
  190. .bottom-line {
  191. position: absolute;
  192. left: 0;
  193. bottom: 0;
  194. right: 0;
  195. border-bottom:1px dashed #eee
  196. }
  197. .bottom-wrapper {
  198. height: 2.5rem;
  199. display: flex;
  200. flex-direction: row;
  201. justify-content: space-around;
  202. align-items: stretch;
  203. align-items: center;
  204. }
  205. .bottom-left-wrapper {
  206. display: flex;
  207. flex-direction: row;
  208. justify-content: flex-start;
  209. align-items: center;
  210. }
  211. .bottom-right-wrapper {
  212. flex: 1;
  213. display: flex;
  214. flex-direction: row;
  215. justify-content: flex-end;
  216. align-items: stretch;
  217. }
  218. .edit-wrapper {
  219. display: flex;
  220. flex-direction: row;
  221. justify-content: flex-start;
  222. align-items: center;
  223. }
  224. .delete-wrapper {
  225. margin-right: 0.5rem;
  226. }
  227. .subtitle {
  228. font-size:$subFontSize;
  229. color: $descTextColor;
  230. }
  231. .subtitle .i{font-size:$h2;margin-right:.5rem;}
  232. }
  233. </style>