myaddressbook.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="content">
  3. <back :title="titlename"></back>
  4. <!-- table切换 -->
  5. <div class="tab">
  6. <div>
  7. <p @click="tab(1)" :class="[index==1?'active':'']">寄件人</p>
  8. <p @click="tab(2)" :class="[index==2?'active':'']" class="">收件人</p>
  9. </div>
  10. </div>
  11. <!-- 寄件人 -->
  12. <div v-if="index==1">
  13. <div class="jjinfo" v-for="item in addressList">
  14. <div>
  15. <div class="jj">
  16. <div class="jjaddress">
  17. <p>寄</p>
  18. <div :id="'copytkl'+item.id">
  19. <p>{{item.name}} {{item.phone}}</p>
  20. <p>{{item.provinceAndCity}} {{item.address}}</p>
  21. </div>
  22. </div>
  23. <div class="cz">
  24. <p @click="del(item.id)">
  25. <img src="../assets/images/del.png" alt="">
  26. <span>删除</span>
  27. </p>
  28. <p @click="linkEdit(item.id)">
  29. <img src="../assets/images/whrite.png" alt="">
  30. <span>编辑</span>
  31. </p>
  32. <p :id="'fz'+item.id" @click="copyLink(item.id)" data-clipboard-action="copy" :data-clipboard-target="'#copytkl'+item.id">
  33. <img src="../assets/images/copy.png" alt="">
  34. <span>复制</span>
  35. </p>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <!-- 寄件 -->
  41. <div class="btn-jj">
  42. <van-button @click="link(1)" type="info" color="#00c4b8">添加寄件人</van-button>
  43. </div>
  44. </div>
  45. <!-- 收件人 -->
  46. <div v-if="index==2">
  47. <div class="jjinfo" v-for="item in addressList">
  48. <div>
  49. <div class="jj">
  50. <div class="jjaddress">
  51. <p style="background: #fa9c22;">收</p>
  52. <div :id="'copytkl'+item.id">
  53. <p>{{item.name}} {{item.phone}}</p>
  54. <p>{{item.provinceAndCity}} {{item.address}}</p>
  55. </div>
  56. </div>
  57. <div class="cz">
  58. <p @click="del(item.id)">
  59. <img src="../assets/images/del.png" alt="">
  60. <span>删除</span>
  61. </p>
  62. <p @click="linkEdit(item.id)">
  63. <img src="../assets/images/whrite.png" alt="">
  64. <span>编辑</span>
  65. </p>
  66. <p :id="'fz'+item.id" @click="copyLink(item.id)" data-clipboard-action="copy" :data-clipboard-target="'#copytkl'+item.id">
  67. <img src="../assets/images/copy.png" alt="">
  68. <span>复制</span>
  69. </p>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. <!-- 寄件 -->
  75. <div class="btn-jj">
  76. <van-button type="info" @click="link(2)" color="#fa9c22">添加收件人</van-button>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import {Toast,Dialog} from 'vant'
  83. export default{
  84. data(){
  85. return {
  86. titlename:"地址簿",
  87. index:1,
  88. userId:'',
  89. addressList:[]
  90. }
  91. },
  92. created:function(){
  93. this.isLogin();
  94. this.userId = localStorage.getItem("userId")
  95. //获取参数
  96. this.index = this.$route.query.active
  97. this.getData();
  98. },
  99. methods:{
  100. //复制
  101. copyLink(id) {
  102. let _this = this;
  103. let clipboard = new this.clipboard("#fz"+id);
  104. clipboard.on('success', function () {
  105. //window.console.log('00')
  106. });
  107. clipboard.on('error', function () {
  108. _this.$toast("复制失败")
  109. });
  110. },
  111. tab(obj){
  112. this.index=obj
  113. this.getData()
  114. },
  115. link(obj){
  116. this.$router.push({path:"/Newaddress",query:{type:obj}})
  117. },
  118. getData(){
  119. Toast.loading({
  120. message: '加载中...',
  121. forbidClick: true,
  122. duration:0
  123. });
  124. this.$http.post(this.$store.state.host+"/personal/getAddressList.do",{userId:this.userId,type:this.index},{emulateJSON:true})
  125. .then(res=>{
  126. //发送成功
  127. if(res.body.msg=='success'){
  128. this.addressList = res.body.addressList
  129. }
  130. Toast.clear()
  131. },res=>{
  132. //发送失败
  133. Toast("网络错误!")
  134. })
  135. Toast.clear()
  136. },
  137. del(id){
  138. Dialog.confirm({ title: '', message: '确定删除吗', })
  139. .then(() => {
  140. Toast.loading({
  141. message: '删除中...',
  142. forbidClick: true,
  143. duration:0
  144. });
  145. this.$http.post(this.$store.state.host+"/personal/deleteAddressInfoById.do",{id:id},{emulateJSON:true})
  146. .then(res=>{
  147. //发送成功
  148. if(res.body.msg=='success'){
  149. this.getData()
  150. }else{
  151. Toast("删除失败!")
  152. }
  153. Toast.clear()
  154. },res=>{
  155. //发送失败
  156. Toast("网络错误!")
  157. })
  158. Toast.clear()
  159. })
  160. .catch(() => {
  161. // on cancel
  162. })
  163. },
  164. //跳去编辑页
  165. linkEdit(id){
  166. this.$router.push({path:"/Editaddress",query:{id:id}})
  167. },
  168. adressLink(item){
  169. let jjInfo = {}
  170. jjInfo.jjname = item.name+' '+item.phone
  171. jjInfo.jjadd = item.provinceAndCity+' '+item.address
  172. jjInfo.sender = item.name
  173. jjInfo.senderPhone = item.phone
  174. jjInfo.sendAddr = item.provinceAndCity
  175. jjInfo.sendAddress = item.address
  176. this.$store.commit("getJjInfo",jjInfo)
  177. this.$router.push({path:"/Express"})
  178. },
  179. adressLinkSj(item){
  180. let sjInfo = {}
  181. sjInfo.sjname = item.name+' '+item.phone
  182. sjInfo.sjadd = item.provinceAndCity+' '+item.address
  183. sjInfo.receiver = item.name
  184. sjInfo.receiverPhone = item.phone
  185. sjInfo.receiveAddr = item.provinceAndCity
  186. sjInfo.receiveAddress = item.address
  187. this.$store.commit("getSjInfo",sjInfo)
  188. this.$router.push({path:"/Express"})
  189. }
  190. },
  191. computed:{
  192. }
  193. }
  194. </script>
  195. <style scoped lang="less">
  196. .content{
  197. .tab{
  198. font-size: .36rem;
  199. color: #00c4b8;
  200. padding: .33rem;
  201. div{
  202. display: flex;
  203. border: .01rem solid #00c4b8;
  204. text-align: center;
  205. border-radius: .05rem;
  206. p{
  207. flex: 1;
  208. padding: .1rem 0rem;
  209. }
  210. p.active{
  211. background: #00c4b8;
  212. color: white;
  213. }
  214. }
  215. }
  216. .jjinfo{
  217. font-size: .36rem;
  218. color: #999999;
  219. padding: .0rem .33rem 0.33rem;
  220. word-break: break-word;
  221. >div{
  222. background: white;
  223. border-radius: .05rem;
  224. padding: .1rem .3rem;
  225. .jj{
  226. display: flex;
  227. justify-content: space-between;
  228. padding: .2rem 0rem;
  229. flex-wrap: wrap;
  230. .jjaddress{
  231. display: flex;
  232. padding: .1rem 0rem .2rem;
  233. >p{
  234. font-size: .24rem;
  235. font-weight: bold;
  236. display: inline-block;
  237. width:.5rem;
  238. height: .5rem;
  239. background: #00c4b8;
  240. text-align: center;
  241. line-height: .5rem;
  242. color: white;
  243. border-radius: 50%;
  244. margin-right: .3rem;
  245. }
  246. div{
  247. //font-weight: bold;
  248. max-width: 5.2rem;
  249. p:nth-of-type(1){
  250. font-size: .3rem;
  251. color: #333;
  252. margin-bottom: .2rem;
  253. }
  254. p:nth-of-type(2){
  255. font-size: .3rem;
  256. }
  257. }
  258. }
  259. .cz{
  260. border-top: .01rem solid #ededed;
  261. width: 100%;
  262. display: flex;
  263. flex-direction: row-reverse;
  264. font-size: .24rem;
  265. color: #999999;
  266. padding-top: .2rem;
  267. p{
  268. margin-left: .2rem;
  269. img{
  270. width:.22rem;
  271. height: .24rem;
  272. }
  273. span{
  274. position: relative;
  275. top: -.01rem;
  276. }
  277. }
  278. }
  279. }
  280. }
  281. }
  282. .btn-jj{
  283. padding: .33rem;
  284. button{
  285. width: 100%;
  286. }
  287. }
  288. }
  289. </style>