testList.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view class="content">
  3. <view class="bg">
  4. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/8e52ab17eabc4534b3ce56026fd5c624.jpg"></image>
  5. </view>
  6. <mescroll-body top="0rpx" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  7. <view class="test-list">
  8. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  9. <view class="left">
  10. <view class="title ellipsis2">{{ item.name }}</view>
  11. <view class="subtitle ellipsis2">{{ item.title }}</view>
  12. <view class="info-box">
  13. <view class="people-num"><text class="num">{{item.peopleNum}}W</text>人测过</view>
  14. <view class="time">{{item.num}}题 | {{item.time}}分钟</view>
  15. </view>
  16. </view>
  17. <view class="right">
  18. <image :src="item.img" mode="aspectFill"></image>
  19. </view>
  20. </view>
  21. </view>
  22. </mescroll-body>
  23. </view>
  24. </template>
  25. <script>
  26. import {getTestList,getTestDetails} from '@/api/test.js'
  27. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  28. import { mapGetters } from 'vuex';
  29. export default {
  30. mixins: [MescrollMixin],
  31. data() {
  32. return {
  33. mescroll:null,
  34. downOption: { //下拉刷新
  35. use:true,
  36. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  37. },
  38. upOption: {
  39. onScroll:false,
  40. use: true, // 是否启用上拉加载; 默认true
  41. page: {
  42. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  43. size: 10 // 每页数据的数量,默认10
  44. },
  45. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  46. textNoMore:"已经到底了",
  47. empty: {
  48. icon:'https://kntobs.jnmyunl.com/shop/images/no_data.png',
  49. tip: '暂无数据'
  50. }
  51. },
  52. dataList: []
  53. };
  54. },
  55. onShow() {
  56. let str="[{\"name\":\"解析\",\"value\":\"您的癌症风险非常高,紧急采取行动是至关重要的。尽早咨询专业医生,制定针对您情况的癌症预防和治疗计划。此外,改善生活方式和遵循医疗建议也至关重要。\"},{\"name\":\"定义\",\"value\":\"癌症是指异常的细胞生长和扩散,它们可以侵犯和破坏周围的健康组织。癌症种类繁多,可发生在身体的各个部位,如乳腺、肺、结肠、皮肤等。\"},{\"name\":\"风险因素\",\"value\":\"遗传;吸烟、高酒精摄入、不健康饮食和缺乏运动;长期接触致癌物质。\"},{\"name\":\"预防\",\"value\":\"戒烟、保持健康体重、均衡饮食、规律运动等,有助于降低癌症风险。\"},{\"name\":\"治疗\",\"value\":\"癌症治疗方法包括手术、放疗、化疗、免疫疗法等,具体取决于癌症的类型和阶段。\"}]";
  57. let strJson=JSON.parse(str);
  58. console.log("strJson:"+strJson);
  59. },
  60. computed: {
  61. ...mapGetters(['logoimg']),
  62. },
  63. watch: {
  64. logoimg: {
  65. immediate: true, // 页面一进入就检查一次
  66. handler(val) {
  67. return val
  68. }
  69. },
  70. },
  71. //发送给朋友
  72. onShareAppMessage(res) {
  73. if(this.utils.isLogin()){
  74. return {
  75. title: "健康自测",
  76. path: '/pages_index/testList',
  77. imageUrl: this.logoimg//分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  78. }
  79. }
  80. },
  81. //分享到朋友圈
  82. onShareTimeline(res) {
  83. if(this.utils.isLogin()){
  84. return {
  85. title: "健康自测",
  86. imageUrl: this.logoimg //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  87. }
  88. }
  89. },
  90. methods:{
  91. mescrollInit(mescroll) {
  92. this.mescroll = mescroll;
  93. },
  94. /*下拉刷新的回调 */
  95. downCallback(mescroll) {
  96. mescroll.resetUpScroll()
  97. },
  98. upCallback(page) {
  99. //联网加载数据
  100. var that = this;
  101. var data = {
  102. pageNum: page.num,
  103. pageSize: page.size
  104. };
  105. getTestList(data).then(res => {
  106. if(res.code==200){
  107. //设置列表数据
  108. if (page.num == 1) {
  109. that.dataList = res.data.list;
  110. } else {
  111. that.dataList = that.dataList.concat(res.data.list);
  112. }
  113. that.mescroll.endBySize(res.data.list.length, res.data.total);
  114. }else{
  115. uni.showToast({
  116. icon:'none',
  117. title: "请求失败",
  118. });
  119. that.dataList = null;
  120. that.mescroll.endErr();
  121. }
  122. });
  123. },
  124. // 查看详情
  125. showDetail(item) {
  126. uni.navigateTo({
  127. url: './testDetails?tempId=' + item.tempId
  128. })
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss">
  134. .content{
  135. position: relative;
  136. .bg{
  137. position: absolute;
  138. width: 100%;
  139. height: 100%;
  140. image{
  141. width: 100%;
  142. height: 100%;
  143. }
  144. }
  145. }
  146. .test-list{
  147. margin-top: 20upx;
  148. padding: 0 20upx;
  149. .item{
  150. width: 100%;
  151. box-sizing: border-box;
  152. height: 271upx;
  153. background: #FFFFFF;
  154. border: 2px solid rgba(195,154,88,0.35);
  155. box-shadow: -1px 4px 5px 0px rgba(153,102,51,0.25);
  156. border-radius: 12px;
  157. padding: 40upx 30upx;
  158. display: flex;
  159. align-items: center;
  160. justify-content: space-between;
  161. margin-bottom: 20upx;
  162. .left{
  163. flex: 1;
  164. padding-right: 40upx;
  165. display: flex;
  166. flex-direction: column;
  167. justify-content: space-between;
  168. .title{
  169. font-size: 40rpx;
  170. font-family: PingFang SC;
  171. line-height: 48upx;
  172. font-weight: bold;
  173. color: #814E1B;
  174. }
  175. .subtitle{
  176. color: #814E1B;
  177. font-size: 28rpx;
  178. font-family: PingFang SC;
  179. margin: 10rpx 0rpx;
  180. }
  181. .info-box{
  182. width: 100%;
  183. display: flex;
  184. align-items: center;
  185. justify-content: flex-start;
  186. .people-num{
  187. font-size: 24upx;
  188. font-family: PingFang SC;
  189. color: #2BC7B9;
  190. .num{
  191. font-weight: bold;
  192. color: #814E1B;
  193. }
  194. }
  195. .time{
  196. margin-left: 25upx;
  197. font-size: 24upx;
  198. font-family: PingFang SC;
  199. font-weight: 500;
  200. color: #2BC7B9;
  201. }
  202. }
  203. }
  204. .right{
  205. width: 250upx;
  206. height: 190upx;
  207. border-radius: 8upx;
  208. overflow: hidden;
  209. image{
  210. width: 100%;
  211. height: 100%;
  212. }
  213. }
  214. }
  215. }
  216. </style>