multipleaddressbook.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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" @click="adressLink(item)">
  17. <p>寄</p>
  18. <div :id="'copytkl'+item.id">
  19. <p>{{item.name}} {{item.phone}} {{item.telPhone}}</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" @click="adressLinkSj(item)">
  51. <p style="background: #fa9c22;">收</p>
  52. <div :id="'copytkl'+item.id">
  53. <p>{{item.name}} {{item.phone}} {{item.telPhone}}</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.senderMobile = item.telPhone
  175. jjInfo.sendAddr = item.provinceAndCity
  176. jjInfo.sendAddress = item.address
  177. this.$store.commit("getJjInfo",jjInfo)
  178. this.$router.push({path:"/MultipleExpress"})
  179. },
  180. adressLinkSj(items){
  181. let sjInfo = {}
  182. sjInfo.sjname = items.name+' '+items.phone
  183. sjInfo.sjadd = items.provinceAndCity+' '+items.address
  184. sjInfo.receiver = items.name
  185. sjInfo.receiverPhone = items.phone
  186. sjInfo.receiveMobile = items.telPhone
  187. sjInfo.receiveAddr = items.provinceAndCity
  188. sjInfo.receiveAddress = items.address
  189. sjInfo.itemType = '物品'
  190. sjInfo.weight = '1'
  191. sjInfo.itemNum = '1'
  192. sjInfo.wpinfo='物品-1kg'
  193. //判断数组中是否有一条数据的地址相同
  194. let someResult = this.$store.state.sjList.some(function(item) {
  195. return item.receiveAddress == sjInfo.receiveAddress;
  196. });
  197. if(someResult){
  198. Toast("您已添加过该收件人!")
  199. return;
  200. }
  201. this.$store.state.sjList.push(sjInfo)
  202. this.$router.push({path:"/MultipleExpress"})
  203. }
  204. },
  205. computed:{
  206. }
  207. }
  208. </script>
  209. <style scoped lang="less">
  210. .content{
  211. .tab{
  212. font-size: .36rem;
  213. color: #00c4b8;
  214. padding: .33rem;
  215. div{
  216. display: flex;
  217. border: .01rem solid #00c4b8;
  218. text-align: center;
  219. border-radius: .05rem;
  220. p{
  221. flex: 1;
  222. padding: .1rem 0rem;
  223. }
  224. p.active{
  225. background: #00c4b8;
  226. color: white;
  227. }
  228. }
  229. }
  230. .jjinfo{
  231. font-size: .36rem;
  232. color: #999999;
  233. padding: .0rem .33rem 0.33rem;
  234. word-break: break-word;
  235. >div{
  236. background: white;
  237. border-radius: .05rem;
  238. padding: .1rem .3rem;
  239. .jj{
  240. display: flex;
  241. justify-content: space-between;
  242. padding: .2rem 0rem;
  243. flex-wrap: wrap;
  244. .jjaddress{
  245. display: flex;
  246. padding: .1rem 0rem .2rem;
  247. >p{
  248. font-size: .24rem;
  249. font-weight: bold;
  250. display: inline-block;
  251. width:.5rem;
  252. height: .5rem;
  253. background: #00c4b8;
  254. text-align: center;
  255. line-height: .5rem;
  256. color: white;
  257. border-radius: 50%;
  258. margin-right: .3rem;
  259. }
  260. div{
  261. //font-weight: bold;
  262. max-width: 5.2rem;
  263. p:nth-of-type(1){
  264. font-size: .3rem;
  265. color: #333;
  266. margin-bottom: .2rem;
  267. }
  268. p:nth-of-type(2){
  269. font-size: .3rem;
  270. }
  271. }
  272. }
  273. .cz{
  274. border-top: .01rem solid #ededed;
  275. width: 100%;
  276. display: flex;
  277. flex-direction: row-reverse;
  278. font-size: .24rem;
  279. color: #999999;
  280. padding-top: .2rem;
  281. p{
  282. margin-left: .2rem;
  283. img{
  284. width:.22rem;
  285. height: .24rem;
  286. }
  287. span{
  288. position: relative;
  289. top: -.01rem;
  290. }
  291. }
  292. }
  293. }
  294. }
  295. }
  296. .btn-jj{
  297. padding: .33rem;
  298. button{
  299. width: 100%;
  300. }
  301. }
  302. }
  303. </style>