transmit.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view>
  3. <uni-nav-bar statusBar backgroundColor="#fff" fixed title="我要转发" left-icon="left" @clickLeft="utils.navigateBack()">
  4. </uni-nav-bar>
  5. <view class="search-view fx-h fx-bc fx-ac">
  6. <u--input
  7. placeholder="搜索联系人"
  8. prefixIcon="search"
  9. clearable
  10. border="none"
  11. prefixIconStyle="font-size: 22px;color: #909399"
  12. v-model="popKeyword"
  13. @input="tapPopKeyWord"
  14. ></u--input>
  15. </view>
  16. <view style="padding: 10px;border-radius: 4px;">
  17. <view class="item fx-r fx-bc" @tap="taopPopItem(item2)" v-for="(item2,index2) in data">
  18. <image :src="item2.img" mode="aspectFill"></image>
  19. <view class="info fx-h fx-ac">
  20. <rich-text class="title" :nodes="getRanValue(item2.name)"></rich-text>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="app-win fx-h fx-bc fx-ac" v-if="isPop">
  25. <view class="bg"></view>
  26. <view class="body">
  27. <view class="title">发送给:</view>
  28. <view class="nicknam-info fx-r fx-bc">
  29. <image :src="showData.img" mode="aspectFill"></image>
  30. <view class="nickname">{{showData.name}}</view>
  31. </view>
  32. <view class="img fx-h fx-bc fx-ac" v-if="inData.type == 'img'">
  33. <image :src="inData.data" mode="widthFix"></image>
  34. </view>
  35. <view class="text" v-if="inData.type == 'text'">
  36. {{inData.data}}
  37. </view>
  38. <view class="voice" v-if="inData.type == 'voice'" @tap="playa">
  39. <view class="i"></view>
  40. <text style="color: 2c2c2c;,margin-right: 3rpx;margin-right: 60px;">{{parseInt(inData.indata.time/1000)}} "</text>
  41. <image v-if="playlyurl != inData.indata.filePath" src="/static/chat/yyy.png" style="width: 15px;height: 15px; margin-left:4px;" mode="widthFix"></image>
  42. <image v-if="playlyurl == inData.indata.filePath" src="/static/chat/yyy.gif" style="width: 15px;height: 15px; margin-left:4px;" mode="widthFix"></image>
  43. </view>
  44. <view class="btns fx-r">
  45. <view class="btn" @tap="isPop = false">取消</view>
  46. <view class="btn btn2" @tap="tapSend">确认</view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <style lang="scss">
  53. .search-view{background: #fff;margin-top: 1px;padding: 10px;}
  54. .search-view .u-input{width: 100%;}
  55. .item{background: #fff;padding:0 10px;position: relative;}
  56. .item:active{background: #f1f1f1;}
  57. .item image{width: 40px;height: 40px;border-radius: 50%;}
  58. .item .info{width: calc(100% - 70px);margin-left: 10px;font-size: 14px;color:#787878;border-bottom: 1px solid #f1f1f1;height: 60px;}
  59. .item .flg{background: #ff5857;width: 20px;height: 20px;border-radius: 50%;font-size: 10px;text-align: center;line-height: 20px;color: #fff;}
  60. .item:last-child .info{border-bottom: 0;}
  61. .letter{padding: 10px;background: #F8F6F6;}
  62. .app-win{ position: fixed;width: 100%;height: 100%;top: 0;left: 0;z-index: 9;}
  63. .app-win .bg{background: rgba(0, 0, 0, 0.5); width: 100%;height: 100%;top: 0;left: 0;position: absolute;}
  64. .app-win .body{background: #fff;border-radius: 12px;position: relative;z-index: 8;padding-bottom: 0;width: 80%;}
  65. .app-win .body .title{padding: 10px;}
  66. .nicknam-info{padding: 10px;}
  67. .nicknam-info image{width: 40px;height: 40px;border-radius: 40px;}
  68. .nicknam-info .nickname{margin-left: 8px;}
  69. .text{font-size: 14px;padding: 30px;}
  70. .voice{margin: 10px;position: relative;min-height: 20px;font-size: 16px;background-color: #cceaff;max-width: calc(100% - 140rpx);padding: 20rpx;border-radius: 8rpx;word-break:break-all;display:inline-block;}
  71. .voice .i{width: 0;height: 0;right: -10px;position: absolute;border-top: 10px solid transparent; border-left: 10px solid #cceaff; border-bottom: 10px solid transparent;}
  72. .btns{height: 45px;border-radius: 0px 0px 12px 12px;}
  73. .btns .btn{ width: 50%;text-align: center;line-height: 45px;color: #787878;}
  74. .btns .btn2{background: $ic-appcolor;color: #fff;border-radius: 0 0 6px 0;}
  75. .btns .btn2:hover,.btns .btn:hover{opacity: .5;}
  76. .img image{width: 150px;margin: 10px 0;}
  77. </style>
  78. <script>
  79. import {mapState,mapMutations } from 'vuex';
  80. export default {
  81. computed: mapState(['user','sysData']),
  82. data() {
  83. return {
  84. msgId : "",
  85. /**提醒人**/
  86. isPop : false,
  87. toView : "",
  88. chatUserList: [],
  89. letter : [],
  90. popKeyword : "",
  91. popItemIn : [],
  92. data : [],
  93. dataAr : [],
  94. showData : {},
  95. inAr : {},
  96. playlyurl : ""
  97. }
  98. },
  99. onLoad(option){
  100. this.msgId = option.msgId || "";
  101. this.inData = {data:option.data || "",type:option.type};
  102. if(option.type == 'voice') {
  103. this.inData.indata = JSON.parse(option.data);
  104. }
  105. this.initView();
  106. },
  107. methods: {
  108. //
  109. initView:function(){
  110. uni.showLoading({ title:"加载中.."});
  111. this
  112. .request
  113. .get("chatListAll")
  114. .then(res=>{
  115. if(res.code == 200) {
  116. this.dataAr = res.data;
  117. uni.hideLoading();
  118. this.letterView();
  119. } else {
  120. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  121. }
  122. });
  123. },
  124. /**
  125. * 搜索观察家
  126. */
  127. tapPopKeyWord:function(){
  128. this.letterView();
  129. },
  130. /**
  131. * 排队数据
  132. */
  133. letterView:function(){
  134. var tAr = [];
  135. for(var j in this.dataAr) {
  136. var jAr = this.dataAr[j];
  137. if(jAr.name.indexOf(this.popKeyword) >= 0) {
  138. tAr.push(jAr);
  139. }
  140. }
  141. console.log(tAr);
  142. this.data = tAr;
  143. },
  144. /**
  145. * 遍历字符串
  146. */
  147. getRanValue:function(str) {
  148. let value = str;
  149. if (value.indexOf(this.popKeyword)!==-1) {
  150. let reg = new RegExp(this.popKeyword, 'gi')
  151. return value.replace(reg, `<font style="color:#2fbec0">${this.popKeyword}</font>`)
  152. } else {
  153. return value
  154. }
  155. },
  156. /**
  157. * 点击事件
  158. */
  159. taopPopItem:function(item){
  160. this.isPop = true;
  161. this.showData = item;
  162. },
  163. /**
  164. * 发送数据
  165. */
  166. tapSend:function(){
  167. uni.showLoading({ title: '提交中..' });
  168. this
  169. .request
  170. .post("forwarding",{
  171. groupId : this.showData['group_id'],
  172. ...this.inData
  173. })
  174. .then(res=>{
  175. uni.hideLoading();
  176. if(res.code == 200) {
  177. this.utils.Tip("发送成功");
  178. setTimeout(()=>{
  179. uni.navigateBack();
  180. },200);
  181. } else {
  182. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  183. }
  184. })
  185. .catch(err=>{
  186. uni.hideLoading();
  187. uni.showModal({title: '系统提示',content: '加载失败,返回在尝试',showCancel: false});
  188. });
  189. },
  190. /**
  191. *
  192. */
  193. groupSendClose:function(){
  194. uni.navigateBack({ delta:1 });
  195. },
  196. playa:function(){
  197. var innerAudioContext = uni.createInnerAudioContext();
  198. innerAudioContext.autoplay = true;
  199. if(this.playlyurl == this.inData.indata.filePath){
  200. this.playlyurl = ''
  201. innerAudioContext.stop()
  202. }else{
  203. this.playlyurl = this.inData.indata.filePath
  204. innerAudioContext.src = this.inData.indata.filePath
  205. innerAudioContext.play()
  206. innerAudioContext.onEnded(()=>{
  207. this.playlyurl = ''
  208. })
  209. }
  210. },
  211. }
  212. }
  213. </script>