addressView.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div class="address_info">
  3. <div class="add_rule">
  4. <a @click="editClick()"><i class="iconfont icon-add"></i>{{isSend ? '新增发货地址' : '新增收货地址'}}</a>
  5. </div>
  6. <div class="deleteKuang" v-if="showLogout">
  7. <div class="kuangContent">
  8. <div class="title">系统提示</div>
  9. <div class="titleinfo">是否删除?</div>
  10. <div class="K_btn">
  11. <div class="cancelBtn" @click="showLogout = false">取消</div>
  12. <div class="answerBtn" @click="goNext">确定</div>
  13. </div>
  14. </div>
  15. </div>
  16. <ul class="list-unstyled">
  17. <li v-for="(item, index) in addressList">
  18. <div class="wrapper-line clearfix">
  19. <div class="name pull-left">{{isSend ? '发货地址:' : '收货地址:'}}</div>
  20. <div class="name-text">{{item.area}}{{item.detailAddress}}</div>
  21. </div>
  22. <div class="wrapper-line clearfix">
  23. <div class="name pull-left">{{isSend ? '发货人:' : '收货人:'}}</div>
  24. <div class="name-text">{{item.name}}</div>
  25. </div>
  26. <div class="wrapper-line clearfix">
  27. <div class="name pull-left">电话:</div>
  28. <div class="name-text">{{item.tel}}</div>
  29. </div>
  30. <div class="item-bottom clearfix">
  31. <div class="pull-left" >
  32. <label class="bottom-modal-check mobile-cart-check" :class="{active: item.num === 1}">
  33. <input type="checkbox" @change="setActiveClick(item.id)">
  34. <span>默认地址</span>
  35. </label>
  36. </div>
  37. <div class="pull-right" >
  38. <span @click="editClick(item)"><i class="iconfont icon-edit"></i>修改</span>
  39. <span @click="deleteClick(item.id, index)"><i class="iconfont icon-lajitong"></i>删除</span>
  40. </div>
  41. </div>
  42. </li>
  43. </ul>
  44. <pull-up
  45. :searchMore="fetching"
  46. :allPage="allPage"
  47. :page="param.page"
  48. :fixId="'logisticsContent'"
  49. @pullUpAction="getPullAddress">
  50. </pull-up>
  51. </div>
  52. </template>
  53. <script type="text/javascript">
  54. import { PullUp } from '~components/mobile/common'
  55. export default {
  56. name: 'AddressInfoView',
  57. props: {
  58. isSend: {
  59. default: true,
  60. type: Boolean
  61. }
  62. },
  63. data() {
  64. return {
  65. addressList: [],
  66. showLogout: false,
  67. // 保存操作数据的序号
  68. saveId: {
  69. id: '',
  70. active: 0
  71. },
  72. param: {
  73. count: 10,
  74. page: 1,
  75. sorting: { 'num': 'asc' }
  76. },
  77. isChange: false
  78. }
  79. },
  80. watch: {
  81. 'listInfo': {
  82. handler: function (val) {
  83. val.content = val.content.sort((a, b) => { return a.num - b.num })
  84. if (this.isChange) {
  85. this.addressList = val.content
  86. this.isChange = false
  87. } else {
  88. this.addressList = [...this.addressList, ...val.content]
  89. }
  90. },
  91. immediate: true
  92. }
  93. },
  94. methods: {
  95. // 设置默认地址
  96. setActiveClick (type) {
  97. this.$http.put(`/trade/address/settop/${type}`).then(() => {
  98. this.initList()
  99. })
  100. },
  101. // 删除事件
  102. deleteClick (type, index) {
  103. this.saveId.id = type
  104. this.saveId.active = index
  105. this.showLogout = true
  106. },
  107. goNext() {
  108. if (this.saveId.active === 0) {
  109. this.setActiveClick(this.addressList[1].id)
  110. }
  111. this.$http.put(`/trade/address/delete/${this.saveId.id}`)
  112. .then(() => {
  113. this.initList()
  114. this.showLogout = false
  115. })
  116. },
  117. // 编辑事件
  118. editClick (type) {
  119. this.$emit('isEditEvent', type || {}, true)
  120. },
  121. // 加载更多
  122. getPullAddress() {
  123. this.param.page++
  124. this.reloadList()
  125. },
  126. // 初始化数据页面
  127. initList () {
  128. this.isChange = true
  129. this.param.page = 1
  130. this.reloadList()
  131. },
  132. // 发送请求数据
  133. reloadList () {
  134. this.$store.dispatch('mobileAddress/loadAddressData', {count: this.param.count, page: this.param.page, isSend: this.isSend, sorting: this.param.sorting})
  135. }
  136. },
  137. computed: {
  138. listInfo() {
  139. return this.baseUtils.deepCopy(this.$store.state.mobileAddress.address.data)
  140. },
  141. fetching () {
  142. return this.$store.state.mobileAddress.address.fetching
  143. },
  144. allPage() {
  145. return this.listInfo.totalPages
  146. }
  147. },
  148. components: {
  149. PullUp
  150. }
  151. }
  152. </script>
  153. <style lang="scss" scoped>
  154. @mixin overFlowHidden {
  155. overflow: hidden;
  156. text-overflow: ellipsis;
  157. white-space: nowrap;
  158. }
  159. @mixin lineHeight($value) {
  160. height: $value;
  161. line-height: $value;
  162. }
  163. .deleteKuang {
  164. position: fixed;
  165. background: rgba(0,0,0,0.5);
  166. top: 0;
  167. left: 0;
  168. right: 0;
  169. bottom: 0;
  170. z-index: 9999;
  171. .kuangContent {
  172. border-radius: 5px;
  173. background: #fff;
  174. width: 5rem;
  175. position: absolute;
  176. left: 50%;
  177. top: 50%;
  178. transform: translate3d(-50%, -50%, 0);
  179. overflow: hidden;
  180. .titleinfo {
  181. font-size: .3rem;
  182. color: #666;
  183. text-align: center;
  184. margin-top: 0.5rem;
  185. margin-bottom: 0.1rem;
  186. }
  187. .title {
  188. background: #5078cb;
  189. height: .7rem;
  190. line-height: .7rem;
  191. font-size: .3rem;
  192. color: #fff;
  193. text-align: center;
  194. }
  195. .info {
  196. color: #f00;
  197. text-align: center;
  198. }
  199. .K_btn {
  200. margin-top: 0.4rem;
  201. line-height: 0.7rem;
  202. height: 0.7rem;
  203. &::after{
  204. clear: both;
  205. display: block;
  206. content: ' ';
  207. visibility: hidden;
  208. zoom: 1;
  209. }
  210. div {
  211. float: left;
  212. width: 50%;
  213. font-size: 0.3rem;
  214. text-align: center;
  215. &.cancelBtn {
  216. background: #b4b5b9;
  217. color: #333;
  218. }
  219. &.answerBtn {
  220. background: #5078cb;
  221. color: #fff;
  222. }
  223. }
  224. }
  225. }
  226. }
  227. .add_rule{
  228. position:absolute;
  229. bottom:.2rem;
  230. left:0;
  231. right:0;
  232. a{
  233. display:block;
  234. margin: 0 auto;
  235. width:95%;
  236. height:.78rem;
  237. line-height: .78rem;
  238. text-align: center;
  239. font-size: .32rem;
  240. color:#fff;
  241. background: #3f84f6;
  242. border-radius:.05rem;
  243. i{
  244. margin-right:.05rem;
  245. }
  246. }
  247. }
  248. .address_info{
  249. padding:.2rem .2rem 1.2rem;
  250. ul {
  251. li {
  252. margin-bottom: 0.2rem;
  253. padding: 0.3rem 0.24rem 0;
  254. border: 1px solid #e4e6e9;
  255. border-radius: 5px;
  256. background: #fefefe;
  257. .wrapper-line {
  258. margin-bottom: 0.16rem;
  259. .name{
  260. display:inline-block;
  261. text-align: right;
  262. width:1.4rem;
  263. font-size: .28rem;
  264. color: #4c8cf7;
  265. }
  266. .name-text {
  267. margin-left:1.4rem;
  268. word-break: break-all;
  269. word-wrap: break-word;
  270. font-size: 0.28rem;
  271. color: #333;
  272. }
  273. }
  274. .item-bottom {
  275. color: #333;
  276. @include lineHeight(0.8rem);
  277. font-size: 0.26rem;
  278. text-align: center;
  279. border-top: 1px solid #d3d3d3;
  280. .pull-left {
  281. text-align: left;
  282. }
  283. .pull-right {
  284. width: 50%;
  285. text-align: right;
  286. }
  287. span{
  288. font-size: 0.28rem;
  289. margin-right:.2rem;
  290. i {
  291. font-size: 0.34rem;
  292. vertical-align: middle;
  293. }
  294. }
  295. }
  296. }
  297. }
  298. }
  299. </style>