addressView.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. if (this.addressList.length <= 0) {
  91. this.editClick()
  92. }
  93. },
  94. immediate: true
  95. }
  96. },
  97. methods: {
  98. // 设置默认地址
  99. setActiveClick (type) {
  100. this.$http.put(`/trade/address/settop/${type}`).then(() => {
  101. this.initList()
  102. })
  103. },
  104. // 删除事件
  105. deleteClick (type, index) {
  106. this.saveId.id = type
  107. this.saveId.active = index
  108. this.showLogout = true
  109. },
  110. goNext() {
  111. this.$http.put(`/trade/address/delete/${this.saveId.id}`)
  112. .then(() => {
  113. this.showLogout = false
  114. if (this.saveId.active === 0 && this.addressList.length > 1) {
  115. this.setActiveClick(this.addressList[1].id)
  116. } else {
  117. this.initList()
  118. }
  119. })
  120. },
  121. // 编辑事件
  122. editClick (type) {
  123. this.$emit('isEditEvent', type || {}, true)
  124. },
  125. // 加载更多
  126. getPullAddress() {
  127. this.param.page++
  128. this.reloadList()
  129. },
  130. // 初始化数据页面
  131. initList () {
  132. this.isChange = true
  133. this.param.page = 1
  134. this.reloadList()
  135. },
  136. // 发送请求数据
  137. reloadList () {
  138. this.$store.dispatch('mobileAddress/loadAddressData', {count: this.param.count, page: this.param.page, isSend: this.isSend, sorting: this.param.sorting, _type: 'ship'})
  139. }
  140. },
  141. computed: {
  142. listInfo() {
  143. return this.baseUtils.deepCopy(this.$store.state.mobileAddress.address.data)
  144. },
  145. fetching () {
  146. return this.$store.state.mobileAddress.address.fetching
  147. },
  148. allPage() {
  149. return this.listInfo.totalPages
  150. }
  151. },
  152. components: {
  153. PullUp
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. @mixin overFlowHidden {
  159. overflow: hidden;
  160. text-overflow: ellipsis;
  161. white-space: nowrap;
  162. }
  163. @mixin lineHeight($value) {
  164. height: $value;
  165. line-height: $value;
  166. }
  167. .deleteKuang {
  168. position: fixed;
  169. background: rgba(0,0,0,0.5);
  170. top: 0;
  171. left: 0;
  172. right: 0;
  173. bottom: 0;
  174. z-index: 9999;
  175. .kuangContent {
  176. border-radius: 5px;
  177. background: #fff;
  178. width: 5rem;
  179. position: absolute;
  180. left: 50%;
  181. top: 50%;
  182. transform: translate3d(-50%, -50%, 0);
  183. overflow: hidden;
  184. .titleinfo {
  185. font-size: .3rem;
  186. color: #666;
  187. text-align: center;
  188. margin-top: 0.5rem;
  189. margin-bottom: 0.1rem;
  190. }
  191. .title {
  192. background: #5078cb;
  193. height: .7rem;
  194. line-height: .7rem;
  195. font-size: .3rem;
  196. color: #fff;
  197. text-align: center;
  198. }
  199. .info {
  200. color: #f00;
  201. text-align: center;
  202. }
  203. .K_btn {
  204. margin-top: 0.4rem;
  205. line-height: 0.7rem;
  206. height: 0.7rem;
  207. &::after{
  208. clear: both;
  209. display: block;
  210. content: ' ';
  211. visibility: hidden;
  212. zoom: 1;
  213. }
  214. div {
  215. float: left;
  216. width: 50%;
  217. font-size: 0.3rem;
  218. text-align: center;
  219. &.cancelBtn {
  220. background: #b4b5b9;
  221. color: #333;
  222. }
  223. &.answerBtn {
  224. background: #5078cb;
  225. color: #fff;
  226. }
  227. }
  228. }
  229. }
  230. }
  231. .add_rule{
  232. position:absolute;
  233. bottom:.2rem;
  234. left:0;
  235. right:0;
  236. a{
  237. display:block;
  238. margin: 0 auto;
  239. width:95%;
  240. height:.78rem;
  241. line-height: .78rem;
  242. text-align: center;
  243. font-size: .32rem;
  244. color:#fff;
  245. background: #3f84f6;
  246. border-radius:.05rem;
  247. i{
  248. margin-right:.05rem;
  249. }
  250. }
  251. }
  252. .address_info{
  253. padding: 0 .2rem 1.2rem;
  254. ul {
  255. li {
  256. margin-top: 0.2rem;
  257. padding: 0.3rem 0.24rem 0;
  258. border: 1px solid #e4e6e9;
  259. border-radius: 5px;
  260. background: #fefefe;
  261. .wrapper-line {
  262. margin-bottom: 0.16rem;
  263. .name{
  264. display:inline-block;
  265. text-align: right;
  266. width:1.5rem;
  267. font-size: .28rem;
  268. color: #4c8cf7;
  269. }
  270. .name-text {
  271. margin-left:1.5rem;
  272. word-break: break-all;
  273. word-wrap: break-word;
  274. font-size: 0.28rem;
  275. color: #333;
  276. }
  277. }
  278. .item-bottom {
  279. color: #333;
  280. @include lineHeight(0.8rem);
  281. font-size: 0.26rem;
  282. text-align: center;
  283. border-top: 1px solid #d3d3d3;
  284. .pull-left {
  285. text-align: left;
  286. }
  287. .pull-right {
  288. width: 50%;
  289. text-align: right;
  290. }
  291. span{
  292. font-size: 0.28rem;
  293. margin-right:.2rem;
  294. i {
  295. font-size: 0.34rem;
  296. vertical-align: middle;
  297. }
  298. }
  299. }
  300. }
  301. }
  302. }
  303. </style>