AddressList.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false"><view class="div distributor-address-list">
  3. <view class="div common-header-wrap">
  4. <view :style="'height:'+navHeight+'px'"></view>
  5. <view class="common-header-holder"></view>
  6. <view class="common-header-fixed">
  7. <title-header />
  8. <uni-nav-bar title="收货地址" class="common-header" left-icon="back" @clickLeft="goBack">
  9. </uni-nav-bar>
  10. </view>
  11. </view>
  12. <view class="div pb-30" v-if="address_list.length>0">
  13. <view class="div item" v-for="item in address_list" :key="item.address_id">
  14. <view class="div container">
  15. <view class="div top-wrapper">
  16. <view class="div selected-wrapper">
  17. <view class="div line">
  18. <text class="i icon iconfont">&#xe6d3;</text>
  19. <view class="div line-content">
  20. <view class="div title-wrapper">
  21. <label class="title">{{item.address_realname}}</label>
  22. <label class="title" style="margin-left:1rem;">{{item.address_mob_phone}}</label>
  23. </view>
  24. <view class="div desc address-text">{{item.area_info}}{{item.address_detail}}</view>
  25. <view class="div desc address-text-cityerror" v-if="item.cityerror">门店已失效,请重新编辑收货地址</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.address_is_default == 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)">
  39. <label class="subtitle"><text class='iconfont'>&#xe6e1;</text>编辑</label>
  40. </view>
  41. <view class="div edit-wrapper delete-wrapper" @click="onDelete(item.address_id)">
  42. <label class="subtitle"><text class='iconfont'>&#xe6d8;</text>删除</label>
  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. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  55. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content" :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  56. </uni-popup>
  57. </member-base>
  58. </template>
  59. <script>
  60. import {getFontSize} from '@/util/common'
  61. import TitleHeader from '../../TitleHeader'
  62. import { urlencode } from '@/util/common'
  63. import MemberBase from '../MemberBase'
  64. import EmptyRecord from '../../EmptyRecord'
  65. import { getAddressList, delAddress, editAddress } from '../../../api/memberAddress'
  66. export default {
  67. components:{
  68. TitleHeader,
  69. MemberBase,
  70. EmptyRecord
  71. },
  72. name:'MemberAddressList',
  73. mounted(){
  74. // #ifdef MP-WEIXIN
  75. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  76. // #endif
  77. },
  78. computed:{
  79. fontSize(){
  80. return getFontSize()
  81. },
  82. },
  83. data(){
  84. return {
  85. navHeight: 0,
  86. dialog:{},
  87. address_list: []
  88. }
  89. },
  90. onShow: function () {
  91. this.getAddressList()
  92. },
  93. methods:{
  94. closeDialog(){
  95. },
  96. confirmDialog(value){
  97. uni.showLoading({ title: '加载中' })
  98. delAddress(this.dialog.data).then(
  99. (response) => {
  100. this.getAddressList()
  101. uni.hideLoading()
  102. }, (error) => {
  103. uni.hideLoading()
  104. uni.showToast({icon:'none',title: error.message})
  105. })
  106. },
  107. goBack () {
  108. uni.navigateBack({delta:1})
  109. },
  110. goAdd () {
  111. uni.navigateTo({ url: '/pages/member/address/AddressForm'+'?'+urlencode( { action: 'add' } )})
  112. },
  113. onDefault (address_info) {
  114. address_info.address_is_default = 1
  115. editAddress(address_info, address_info.address_id).then(
  116. (response) => {
  117. uni.hideLoading()
  118. this.getAddressList()
  119. }, (error) => {
  120. uni.hideLoading()
  121. uni.showToast({icon:'none',title: error.message})
  122. })
  123. },
  124. onEdit (address) {
  125. if (!address.chain_id) {
  126. uni.navigateTo({ url: '/pages/member/address/AddressForm'+'?'+urlencode( { address_id: address.address_id } )})
  127. } else {
  128. uni.navigateTo({ url: '/pages/member/address/ChainForm'+'?'+urlencode( { address_id: address.address_id, action: 'edit' } )})
  129. }
  130. },
  131. onDelete (addressId) {
  132. this.dialog={content:'确定要删除该地址吗?',data:addressId}
  133. this.$refs.confirm.open()
  134. },
  135. getAddressList () {
  136. getAddressList().then(res => {
  137. this.address_list = res.result.address_list
  138. }).catch(function (error) {
  139. uni.showToast({icon:'none',title: error.message})
  140. })
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. .distributor-address-list {
  147. .common-header{
  148. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  149. }
  150. .line{display: flex;
  151. .line-content{flex:1}
  152. }
  153. .item{margin-bottom:$modelSpace}
  154. .container{background: #fff;padding:0 $pageSpace}
  155. .top-wrapper {
  156. position: relative;
  157. flex: 1;
  158. display: flex;
  159. flex-direction: row;
  160. justify-content: flex-start;
  161. align-items: center;
  162. background-color: #fff;
  163. }
  164. .title-wrapper {
  165. height: 1rem;
  166. display: flex;
  167. flex-direction: row;
  168. justify-content: flex-start;
  169. align-items: center;
  170. }
  171. .icon {
  172. font-size:$h1;
  173. margin-right: .2rem;
  174. color:$primaryColor
  175. }
  176. .title {
  177. font-size:$h3;
  178. color: #333;
  179. font-weight: 700;
  180. }
  181. .default {
  182. width: 1.4rem;
  183. margin-left: 0.5rem;
  184. margin-right: 0.5rem;
  185. border: 1px solid $primaryColor;
  186. color: $primaryColor;
  187. font-size:$h6;
  188. text-align: center;
  189. border-radius: 0.1rem;
  190. }
  191. .desc {
  192. color: $descTextColor;
  193. font-size:$subFontSize;
  194. }
  195. .address-text {
  196. margin-top: .3rem;
  197. font-weight: normal;
  198. }
  199. .address-text-cityerror{
  200. margin-top: .3rem;
  201. font-weight: normal;
  202. color: #ff4040;
  203. }
  204. .selected-wrapper{
  205. padding:1rem 0;
  206. }
  207. .bottom-line {
  208. position: absolute;
  209. left: 0;
  210. bottom: 0;
  211. right: 0;
  212. border-bottom:1px dashed #eee
  213. }
  214. .bottom-wrapper {
  215. height: 2.5rem;
  216. display: flex;
  217. flex-direction: row;
  218. justify-content: space-around;
  219. align-items: stretch;
  220. align-items: center;
  221. }
  222. .bottom-left-wrapper {
  223. display: flex;
  224. flex-direction: row;
  225. justify-content: flex-start;
  226. align-items: center;
  227. }
  228. .bottom-right-wrapper {
  229. flex: 1;
  230. display: flex;
  231. flex-direction: row;
  232. justify-content: flex-end;
  233. align-items: stretch;
  234. }
  235. .edit-wrapper {
  236. display: flex;
  237. flex-direction: row;
  238. justify-content: flex-start;
  239. align-items: center;
  240. }
  241. .delete-wrapper {
  242. margin-right: 0.5rem;
  243. }
  244. .subtitle {
  245. font-size:$subFontSize;
  246. color: $descTextColor;
  247. margin: .5rem .5rem .5rem 1rem;
  248. }
  249. .subtitle .i{font-size:$h2;margin-right:.5rem;}
  250. .subtitle .iconfont{font-size: .7rem;}
  251. }
  252. </style>