Xiaoxijiaohu.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view>
  3. <customNav :shownav="true" :title="viewTitle" titledetl=""></customNav>
  4. <view class="contentColumn" style="width: 90%;margin-left: 5%;margin-top: 30rpx;">
  5. <view v-for="(item,index) in xiaoxiList">
  6. <view v-if="item.type!=1" class="contentColumn">
  7. <view class="contentInRowL">
  8. <text style="font-size: 32rpx;">{{item.rcuser}}</text>
  9. <text style="font-size: 28rpx;color: darkgray;">{{item.time}}</text>
  10. </view>
  11. <view class="contentInRowL">
  12. <text class="msgctst">{{item.msg}}</text>
  13. </view>
  14. </view>
  15. <view v-if="item.type==1" class="contentColumn">
  16. <view class="contentInRowR">
  17. <text style="font-size: 28rpx;color: darkgray;">{{item.time}}</text>
  18. </view>
  19. <view class="contentInRowR">
  20. <text class="mymsgctst">{{item.msg}}</text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="bottomfloatV">
  26. <view class="contentInRowC" style="height: 180rpx;align-items: flex-start">
  27. <input class="inputVst" type="text" :value="msg" :placeholder="$t('dache.shuruxiaoxi')" @input="msgInput">
  28. <uni-icons class="updatamsg" custom-prefix="custom-icon" color="#1A1A1A" type="plusempty" size="36" @click="onupdatamsg"></uni-icons>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import api from "@/pages/api/api.js"
  35. export default {
  36. data() {
  37. return {
  38. viewTitle:'',
  39. msg:'',
  40. id:'',
  41. obj:'',
  42. xiaoxiList:[]
  43. }
  44. },
  45. onLoad(option) {
  46. var id=option.id;
  47. this.getObjDetail(id);
  48. this.viewTitle='';
  49. uni.onPushMessage((res) => {
  50. console.log('onPushMessage',res);
  51. if(null==res.data.payload||undefined==res.data.payload||''==res.data.payload){
  52. return;
  53. }
  54. this.getxiaoxiList();
  55. });
  56. },
  57. onShow() {
  58. this.getxiaoxiList();
  59. },
  60. methods: {
  61. getxiaoxiList(){
  62. var List = uni.getStorageSync('dachexiaoxi');
  63. if(''==List||null==List||undefined==List){
  64. return;
  65. }
  66. else{
  67. var tempList=[];
  68. for(var i=0;i<List.length;i++){
  69. var tempStr = List[i];
  70. tempList.push(JSON.parse(tempStr));
  71. }
  72. this.xiaoxiList = tempList;
  73. }
  74. },
  75. msgInput(event){
  76. this.msg = event.target.value;
  77. },
  78. getObjDetail(id){
  79. api('getTxorder',{
  80. id:id,
  81. },res=>{
  82. console.log(res)
  83. if(res.data.code==200){
  84. this.obj=res.data.data;
  85. this.viewTitle=this.obj.driver.nickName;
  86. }
  87. },failc=>{
  88. //console.log('getadvertis----',failc)
  89. })
  90. },
  91. onupdatamsg(){
  92. if(this.msg.length>0&&this.obj!=''){
  93. this.pushMsg(this.obj.driver.cid,this.msg)
  94. }
  95. },
  96. pushMsg(cid,msg){//消息推送
  97. var time=new Date();
  98. var n,y,r,h,m,s;
  99. n=time.getFullYear();
  100. y=time.getMonth()+1;
  101. r=time.getDate();
  102. h=time.getHours();
  103. m=time.getMinutes();
  104. s=time.getSeconds();
  105. var timsStr = n+'-'+y+'-'+r+' '+h+':'+m+':'+s;
  106. var payloadData={
  107. rcuser:'尾号:'+this.obj.user.phone.slice(-4),
  108. time:timsStr,
  109. msg:msg,
  110. type:1
  111. }
  112. api('pushMsgQS',{
  113. cid:cid,
  114. title:'New Message',
  115. content:msg,
  116. payload:payloadData
  117. },res=>{
  118. console.log(res)
  119. this.msg='';
  120. var xiaoxiList = uni.getStorageSync('dachexiaoxi');
  121. if(''==xiaoxiList||null==xiaoxiList||undefined==xiaoxiList){
  122. xiaoxiList=[];
  123. }
  124. xiaoxiList.push(JSON.stringify(payloadData));
  125. uni.setStorageSync('dachexiaoxi',xiaoxiList);
  126. this.getxiaoxiList();
  127. },failc=>{
  128. //console.log('getadvertis----',failc)
  129. })
  130. },
  131. }
  132. }
  133. </script>
  134. <style lang="scss">
  135. page{
  136. background-color: #F4F4F4;
  137. }
  138. .msgctst{
  139. font-size: 32rpx;
  140. color: #1a1a1a;
  141. background-color: white;
  142. border-radius: 12rpx;
  143. padding: 16rpx;
  144. }
  145. .mymsgctst{
  146. font-size: 32rpx;
  147. color:white;
  148. background-color: #7a7a7a;
  149. border-radius: 12rpx;
  150. padding: 16rpx;
  151. }
  152. .bottomfloatV{
  153. position: fixed;
  154. flex-direction: column;
  155. justify-content: center;
  156. align-items: center;
  157. left: 0;
  158. right: 0;
  159. bottom: 0;
  160. z-index: 999;
  161. background-color: white;
  162. }
  163. .inputVst{
  164. margin-top: 10rpx;
  165. width: 76%;
  166. background-color: #F4F4F4;
  167. height: 80rpx;
  168. border-radius: 20rpx;
  169. }
  170. .updatamsg{
  171. margin-left: 10rpx;
  172. margin-top: 10rpx;
  173. font-weight: bold;
  174. }
  175. </style>