searchZmt.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="content">
  3. <!--搜索 start-->
  4. <view class="Search-box" @click="">
  5. <view class="Search-box-size">
  6. <image class="box-img" src="../../static/img/img01.png"></image>
  7. <input type="text" class="box-word" placeholder="请输入关键字" v-model="keyword" />
  8. </view>
  9. <view class="Search-box-sort" @click="getList('click')">搜索</view>
  10. </view>
  11. <!-- 搜索 end-->
  12. <!-- 补位 -->
  13. <view class="" style="height: 100rpx;"></view>
  14. <!-- 自媒体列表 start -->
  15. <view class="dy-wrap flex" v-for="item in list" @click="navTo('/pages/user/dydetail?id=' + item.id)">
  16. <view class="user-logo">
  17. <image :src="item.headimg" mode=""></image>
  18. </view>
  19. <view class="user-num">
  20. <view class="user-name">
  21. {{item.name}}
  22. </view>
  23. <view class="sub-num">
  24. 发表文章:{{item.count}}
  25. </view>
  26. <view class="read-num">
  27. 阅读量:{{item.visit}}
  28. </view>
  29. </view>
  30. <view class="flex_direction">
  31. <view class="dy-btn" :class="{'dying':item.is_sub == 1}" @click.stop="dingYue(item)">
  32. {{item.is_sub == 1?'已订阅':'订阅'}}
  33. </view>
  34. <view class="jr-btn" v-if="item.join" :class="{'dying':item.join == 1}" @click.stop='toJoin(item)'>
  35. 已加入
  36. </view>
  37. <view class="jr-btn" style="display: block;" v-if="!item.joins&&!item.join" :class="dying" @click.stop='toJoin(item)'>
  38. 加入
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 自媒体列表 end -->
  43. <!-- <empty v-if=" list.length === 0"></empty> -->
  44. </view>
  45. </template>
  46. <script>
  47. import { searchZmt,dingYue } from '@/api/art.js'
  48. import empty from '@/components/empty';
  49. export default {
  50. components: {
  51. // uniLoadMore,
  52. empty
  53. },
  54. data() {
  55. return {
  56. list: [],
  57. page: 1,
  58. limit: 20,
  59. loadingType: 'more',
  60. keyword: '',
  61. }
  62. },
  63. onReachBottom() {
  64. this.getList()
  65. },
  66. methods: {
  67. navTo(url) {
  68. uni.navigateTo({
  69. url
  70. })
  71. },
  72. getList(type) {
  73. let obj = this
  74. if(type == 'click') {
  75. obj.list = []
  76. obj.page = 1
  77. obj.loadingType = 'more'
  78. }
  79. searchZmt({
  80. page: obj.page,
  81. rows: obj.limit,
  82. name: obj.keyword
  83. }).then(res => {
  84. console.log(res)
  85. obj.list = obj.list.concat(res.data.list)
  86. })
  87. },
  88. //加入
  89. toJoin(item){
  90. if(!this.merId){
  91. this.navTo('/pages/user/joinMedia?id=' + item.id)
  92. }
  93. },
  94. // 订阅
  95. dingYue(item) {
  96. let obj = this
  97. // is_sub 为1 时为关注状态
  98. if(item.is_sub == 1) {
  99. uni.showModal({
  100. title:'提示',
  101. content: '是否取消关注?',
  102. complete(e) {
  103. if(e.confirm) {
  104. // 取消关注
  105. dingYue({
  106. id:item.id
  107. }).then(res => {
  108. console.log(res)
  109. let s = obj.list.indexOf(item);
  110. obj.list[s].is_sub = 0
  111. obj.$api.msg('已取消关注')
  112. })
  113. }
  114. }
  115. })
  116. }else {
  117. // 关注
  118. dingYue({
  119. id:item.id
  120. }).then(res => {
  121. let s = obj.list.indexOf(item);
  122. obj.list[s].is_sub = 1
  123. obj.$api.msg('已关注')
  124. })
  125. }
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .content {
  132. background-color: #fff;
  133. }
  134. .jr-btn {
  135. flex-shrink: 0;
  136. text-align: center;
  137. width: 136rpx;
  138. line-height: 66rpx;
  139. border-radius: 10rpx;
  140. font-size: 28rpx;
  141. font-weight: 500;
  142. margin-top: 20rpx;
  143. background: #E6645F;
  144. color: #fff;
  145. }
  146. .Search-box {
  147. position: absolute;
  148. top: 0;
  149. width: 750rpx;
  150. padding-left: 20rpx;
  151. padding-right: 20rpx;
  152. height: 100rpx;
  153. background: #ffffff;
  154. display: flex;
  155. justify-content: space-around;
  156. align-items: center;
  157. .Search-box-sort {
  158. font-size: 30rpx;
  159. flex-shrink: 0;
  160. font-weight: 500;
  161. color: rgba(102, 102, 102, 1);
  162. .sort-text {
  163. width: 57rpx;
  164. height: 29rpx;
  165. font-size: 30rpx;
  166. font-weight: 500;
  167. color: rgba(51, 51, 51, 1);
  168. line-height: 58rpx;
  169. margin-right: 19rpx;
  170. }
  171. .sort-img {
  172. width: 21rpx;
  173. height: 11rpx;
  174. margin-bottom: 4rpx;
  175. }
  176. }
  177. .Search-box-size {
  178. width: 605rpx;
  179. height: 65rpx;
  180. border-radius: 32rpx;
  181. background-color: #f1f1f1;
  182. padding-left: 36rpx;
  183. display: flex;
  184. align-items: center;
  185. .box-img {
  186. height: 32rpx;
  187. width: 32rpx;
  188. margin-right: 16rpx;
  189. }
  190. .box-word {
  191. padding: 10rpx;
  192. width: 100%;
  193. font-size: 22rpx;
  194. font-weight: 500;
  195. color: rgba(205, 203, 203, 1);
  196. line-height: 55rpx;
  197. height: 60rpx;
  198. color: #000000;
  199. }
  200. }
  201. }
  202. .dy-wrap {
  203. width: 707rpx;
  204. background: #fff;
  205. margin: auto;
  206. border-bottom: #E9E9E9 solid 1px;
  207. padding: 20rpx 0;
  208. .user-logo {
  209. flex-shrink: 0;
  210. height: 100rpx;
  211. width: 100rpx;
  212. border-radius: 50%;
  213. image {
  214. width: 100%;
  215. height: 100%;
  216. border-radius: 50%;
  217. }
  218. }
  219. .user-num {
  220. flex-grow: 1;
  221. padding-left: 10rpx;
  222. font-size: 24rpx;
  223. font-weight: 500;
  224. color: #999999;
  225. .user-name {
  226. font-size: 34rpx;
  227. font-weight: 600;
  228. color: #333333;
  229. padding-right: 20rpx;
  230. padding: 0 20rpx 20rpx 0;
  231. }
  232. }
  233. .dy-btn {
  234. flex-shrink: 0;
  235. text-align: center;
  236. width: 136rpx;
  237. line-height: 66rpx;
  238. border-radius: 10rpx;
  239. font-size: 28rpx;
  240. font-weight: 500;
  241. background: #E6645F;
  242. color: #fff;
  243. }
  244. .dying {
  245. color: #999999;
  246. background: #E9E9E9;
  247. }
  248. }
  249. </style>