noteinfo.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="app">
  3. <uni-nav-bar statusBar backgroundColor="#fff" fixed title="备注信息" left-icon="left" @clickLeft="utils.navigateBack()">
  4. <view slot="right" @tap="tapSubmit">
  5. <view class="sub-btn">完成</view>
  6. </view>
  7. </uni-nav-bar>
  8. <view class="info-view">
  9. <view class="label">备注名</view>
  10. <input type="text" placeholder="请输入备注名" v-model="remark"/>
  11. </view>
  12. <view class="info-name">电话号码</view>
  13. <view class="info-phone">
  14. <view class="phone-item fx-r fx-bc" v-for="(item,index) in phoneAr">
  15. <image @tap="tapRemove(index)" src="/static/chat/reduce.png"></image>
  16. <input type="number" v-model="phoneAr[index]" placeholder="请输入电话号码" />
  17. </view>
  18. <view class="phone-item fx-r fx-bc" @tap="tapAdd">
  19. <image src="/static/chat/re-add.png"></image>
  20. <text>添加电话号码</text>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <style lang="scss">
  26. .sub-btn{color: #fff;background:$ic-appcolor;padding: 8px;border-radius: 4px;}
  27. .info-view{
  28. padding: 10px;
  29. background: #fff;
  30. .label{
  31. color: #000;
  32. font-size: 16px;
  33. }
  34. input{padding: 10px 0;font-size: 14px;}
  35. }
  36. .info-name{color: $ic-default-text;padding: 10px;}
  37. .info-phone{background: #fff;}
  38. .info-phone .phone-item{padding:15px 10px;font-size: 14px;}
  39. .info-phone .phone-item image{width: 20px;height: 20px;margin-right: 4px;}
  40. </style>
  41. <script>
  42. import {mapState,mapMutations } from 'vuex';
  43. export default {
  44. data() {
  45. return {
  46. data : {},
  47. usercode : "",
  48. phoneAr : [],
  49. remark : ""
  50. }
  51. },
  52. onLoad(option){
  53. this.usercode = option.usercode || "";
  54. this.getData();
  55. },
  56. methods: {
  57. getData:function(){
  58. uni.showLoading({ title: '获取数据中..'});
  59. this
  60. .request
  61. .post("chatFriendFind",{usercode:this.usercode})
  62. .then(res => {
  63. uni.hideLoading();
  64. if(res.code == 200) {
  65. this.data = res.data;
  66. if(res.data.friend.phone != "")
  67. this.phoneAr = res.data.friend.phone.split(",");
  68. this.remark = res.data.friend.remark;
  69. } else {
  70. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  71. }
  72. })
  73. .catch(res=>{
  74. console.log(res);
  75. uni.hideLoading();
  76. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  77. });
  78. },
  79. isPhone:function(str){
  80. if(str == '') return [];
  81. return str.split(',');
  82. },
  83. tapSubmit:function(){
  84. var phone = "";
  85. for(var i in this.phoneAr) {
  86. if(this.phoneAr[i] == '') {
  87. uni.showModal({title: '系统提示',content: '请输入手机号码!',showCancel: false});
  88. return;
  89. }
  90. }
  91. phone = this.phoneAr.join(',');
  92. uni.showLoading({ title: '提交中..'});
  93. this
  94. .request
  95. .post("FriendSetRemark",{remark:this.remark,phone:phone,id:this.data.friend.id})
  96. .then(res => {
  97. uni.hideLoading();
  98. if(res.code == 200) {
  99. this.utils.Tip("操作成功");
  100. this.getData();
  101. } else {
  102. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  103. }
  104. })
  105. .catch(res=>{
  106. console.log(res);
  107. uni.hideLoading();
  108. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  109. });
  110. },
  111. /**
  112. * open
  113. * @param {Object} ev
  114. */
  115. tapOpen:function(ev){
  116. let url = ev.currentTarget.dataset.url;
  117. this.utils.navigateTo(url);
  118. },
  119. /**
  120. * 移除数据
  121. * @param {Object} index
  122. */
  123. tapRemove:function(index){
  124. console.log(index);
  125. this.$delete(this.phoneAr,index);
  126. },
  127. /**
  128. * 添加数据
  129. */
  130. tapAdd:function(){
  131. this.phoneAr.push("");
  132. }
  133. }
  134. }
  135. </script>