testList.vue 6.2 KB

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