addressView.vue 7.9 KB

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