addressView.vue 7.8 KB

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