Xiaoxijiaohu.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view>
  3. <customNav :shownav="true" :title="viewTitle" tinColor="white" jiantou="1" ></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!=2" 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==2" 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.qingshurxx')" @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. if(null==res.data.payload||undefined==res.data.payload||''==res.data.payload){
  51. return;
  52. }
  53. this.getxiaoxiList();
  54. });
  55. },
  56. onShow() {
  57. this.getxiaoxiList();
  58. },
  59. methods: {
  60. getxiaoxiList(){
  61. var List = uni.getStorageSync('dachexiaoxi');
  62. if(''==List||null==List||undefined==List){
  63. return;
  64. }
  65. else{
  66. var tempList=[];
  67. for(var i=0;i<List.length;i++){
  68. var tempStr = List[i];
  69. tempList.push(JSON.parse(tempStr));
  70. }
  71. this.xiaoxiList = tempList;
  72. }
  73. },
  74. msgInput(event){
  75. this.msg = event.target.value;
  76. },
  77. getObjDetail(id){
  78. api('getTxorder',{
  79. id:id,
  80. },res=>{
  81. console.log(res)
  82. if(res.data.code==200){
  83. this.obj=res.data.data;
  84. this.viewTitle=this.obj.user.nickName;
  85. }
  86. },failc=>{
  87. //console.log('getadvertis----',failc)
  88. })
  89. },
  90. onupdatamsg(){
  91. if(this.msg.length>0&&this.obj!=''){
  92. this.pushMsg(this.obj.user.cid,this.msg)
  93. }
  94. },
  95. pushMsg(cid,msg){//消息推送
  96. var time=new Date();
  97. var n,y,r,h,m,s;
  98. n=time.getFullYear();
  99. y=time.getMonth()+1;
  100. r=time.getDate();
  101. h=time.getHours();
  102. m=time.getMinutes();
  103. s=time.getSeconds();
  104. var timsStr = n+'-'+y+'-'+r+' '+h+':'+m+':'+s;
  105. var payloadData={
  106. rcuser:'尾号:'+this.obj.driver.phone.slice(-4),
  107. time:timsStr,
  108. msg:msg,
  109. type:2
  110. }
  111. api('pushMsgYH',{
  112. cid:cid,
  113. title:'您有新消息了',
  114. content:msg,
  115. payload:payloadData
  116. },res=>{
  117. console.log(res)
  118. this.msg='';
  119. var xiaoxiList = uni.getStorageSync('dachexiaoxi');
  120. if(''==xiaoxiList||null==xiaoxiList||undefined==xiaoxiList){
  121. xiaoxiList=[];
  122. }
  123. xiaoxiList.push(JSON.stringify(payloadData));
  124. uni.setStorageSync('dachexiaoxi',xiaoxiList);
  125. this.getxiaoxiList();
  126. },failc=>{
  127. //console.log('getadvertis----',failc)
  128. })
  129. },
  130. }
  131. }
  132. </script>
  133. <style lang="scss">
  134. page{
  135. background-color: #F4F4F4;
  136. }
  137. .msgctst{
  138. font-size: 32rpx;
  139. color: #1a1a1a;
  140. background-color: white;
  141. border-radius: 12rpx;
  142. padding: 16rpx;
  143. }
  144. .mymsgctst{
  145. font-size: 32rpx;
  146. color:white;
  147. background-color: #7a7a7a;
  148. border-radius: 12rpx;
  149. padding: 16rpx;
  150. }
  151. .bottomfloatV{
  152. position: fixed;
  153. flex-direction: column;
  154. justify-content: center;
  155. align-items: center;
  156. left: 0;
  157. right: 0;
  158. bottom: 0;
  159. z-index: 999;
  160. background-color: white;
  161. }
  162. .inputVst{
  163. margin-top: 10rpx;
  164. width: 76%;
  165. background-color: #F4F4F4;
  166. height: 80rpx;
  167. border-radius: 20rpx;
  168. }
  169. .updatamsg{
  170. margin-left: 10rpx;
  171. margin-top: 10rpx;
  172. font-weight: bold;
  173. }
  174. </style>