addmsg.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view>
  3. <view class="navbar">
  4. <view v-for="(item, index) in tabList" :key="index" class="nav-item"
  5. :class="{ current: tabCurrentIndex === item.state }" @click="tabClicks(item.state)">
  6. {{ item.text }}
  7. </view>
  8. </view>
  9. <view v-for="(item,index) in list" v-if="tabCurrentIndex == 0" @click="goAdd(1,0,item.id)">
  10. <view
  11. style="margin-top: 20upx;color: #000000;display: flex;align-items: center;background: #FFFFFF;padding: 0rpx 20rpx;">
  12. <view style="height: 80upx;line-height: 80upx;width: 80%;">
  13. {{item.content}}
  14. </view>
  15. <view style="width: 20%;display: flex;justify-content: flex-end;">
  16. <image src="../../static/images/my/right_icon.png" style="width: 15rpx;height: 30rpx;"></image>
  17. </view>
  18. </view>
  19. </view>
  20. <view v-if="tabCurrentIndex == 1 && contentMsg" @click="goAdd(1,1)"
  21. style="margin-top: 20upx;color: #000000;display: flex;align-items: center;background: #FFFFFF;padding: 0rpx 20rpx;">
  22. <view style="height: 80upx;line-height: 80upx;width: 80%;">
  23. {{contentMsg}}
  24. </view>
  25. <view style="width: 20%;display: flex;justify-content: flex-end;">
  26. <image src="../../static/images/my/right_icon.png" style="width: 15rpx;height: 30rpx;"></image>
  27. </view>
  28. </view>
  29. <view class="padding-lr-sm" style="position: fixed;bottom: 40upx;width: 100%;z-index: 999;"
  30. v-if="tabCurrentIndex == 0">
  31. <u-button class="" :custom-style="customStyle1" :hair-line="false" @click="goAdd(0,0)">
  32. <u-icon name="plus" color="#fff" size="30" style="margin-right: 10upx;"></u-icon>
  33. 添加
  34. </u-button>
  35. </view>
  36. <view class="padding-lr-sm" style="position: fixed;bottom: 40upx;width: 100%;z-index: 99999;"
  37. v-if="tabCurrentIndex == 1 && contentMsg == ''">
  38. <u-button class="" :custom-style="customStyle1" :hair-line="false" @click="goAdd(0,1)">
  39. <u-icon name="plus" color="#fff" size="30" style="margin-right: 10upx;"></u-icon>
  40. 添加
  41. </u-button>
  42. </view>
  43. <empty v-if="tabCurrentIndex == 0 && list.length == 0" content='暂无常用语信息'></empty>
  44. <empty v-if="tabCurrentIndex == 1 && contentMsg == ''" content='暂无自动回复信息'></empty>
  45. </view>
  46. </template>
  47. <script>
  48. import empty from '../../components/empty.vue'
  49. export default {
  50. components: {
  51. empty
  52. },
  53. data() {
  54. return {
  55. customStyle1: {
  56. backgroundColor: "#00B88F",
  57. border: 0,
  58. color: "#FFF",
  59. height: '98rpx'
  60. },
  61. contentMsg: '',
  62. tabCurrentIndex: 0,
  63. fromInfo: 5,
  64. limit: 20,
  65. list: [],
  66. page: 1,
  67. scrollTop: false,
  68. tabList: [{
  69. state: 0,
  70. text: '常用词语',
  71. totalElements: 0
  72. },
  73. {
  74. state: 1,
  75. text: '自动回复',
  76. totalElements: 0
  77. }
  78. ]
  79. }
  80. },
  81. onShow() {
  82. this.page = 1;
  83. this.loadData();
  84. },
  85. methods: {
  86. onPageScroll: function(e) {
  87. this.scrollTop = e.scrollTop > 200;
  88. },
  89. onReachBottom: function() {
  90. this.page = this.page + 1;
  91. this.loadData();
  92. },
  93. onPullDownRefresh: function() {
  94. this.page = 1;
  95. this.loadData();
  96. },
  97. goAdd(index, type, id) {
  98. uni.navigateTo({
  99. url: '/pages/msg/add?type=' + index + '&type1=' + type + '&id=' + id
  100. });
  101. },
  102. //顶部渠道点击
  103. tabClicks(index) {
  104. this.list = [];
  105. this.page = 1;
  106. this.tabCurrentIndex = index;
  107. // this.$queue.showLoading("加载中...")
  108. this.loadData();
  109. },
  110. //获取消息列表
  111. loadData() {
  112. let that = this;
  113. let number = 10;
  114. let token = this.$queue.getData('token');
  115. if (token) {
  116. this.$queue.showLoading("加载中...")
  117. if (this.tabCurrentIndex == 0) {
  118. this.$Request.getT('/app/message/selectMessageByUserId?page=' + this.page + '&limit=' + this
  119. .limit +
  120. '&state=20')
  121. .then(res => {
  122. if (res.code == 0) {
  123. if (this.page == 1) {
  124. this.list = [];
  125. }
  126. res.data.list.forEach(d => {
  127. this.list.push(d);
  128. });
  129. }
  130. uni.hideLoading();
  131. });
  132. } else {
  133. this.$Request.get("/app/user/selectUserById").then(res => {
  134. if (res.code == 0) {
  135. this.contentMsg = res.data.msg ? res.data.msg : '';
  136. }
  137. uni.hideLoading();
  138. });
  139. }
  140. }
  141. }
  142. },
  143. onPageScroll: function(e) {
  144. this.scrollTop = e.scrollTop > 200;
  145. },
  146. onReachBottom: function() {
  147. this.page = this.page + 1;
  148. this.loadData();
  149. }
  150. }
  151. </script>
  152. <style lang="scss">
  153. page {
  154. background-color: #F5F5F5;
  155. }
  156. .bg {
  157. background-color: #FFFFFF;
  158. }
  159. .navbar {
  160. display: flex;
  161. height: 40px;
  162. padding: 0 5px;
  163. background: #FFFFFF;
  164. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  165. position: relative;
  166. z-index: 10;
  167. .nav-item {
  168. flex: 1;
  169. display: flex;
  170. justify-content: center;
  171. align-items: center;
  172. height: 100%;
  173. font-size: 15px;
  174. color: #000000;
  175. position: relative;
  176. &.current {
  177. color: #000000;
  178. &:after {
  179. content: '';
  180. position: absolute;
  181. left: 50%;
  182. bottom: 0;
  183. transform: translateX(-50%);
  184. width: 44px;
  185. height: 0;
  186. border-bottom: 2px solid #00B88F;
  187. }
  188. }
  189. }
  190. }
  191. </style>