relatedWorks.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view class="page">
  3. <view class="nav-bar">
  4. <view class="left">
  5. <view class="uni-btn-icon" @click="goBack">&#xe601;</view>
  6. </view>
  7. <view class="center">全部作品</view>
  8. <view class="right">
  9. <view class="btn" @click="onSubmit">确定</view>
  10. </view>
  11. </view>
  12. <view class="listContent">
  13. <view class="list-item" v-for="(item, index) in listItems" :key="index" @click="selectItem(item)">
  14. <view class="img-box">
  15. <image :src="item.images"></image>
  16. </view>
  17. <view class="info">
  18. <view class="title">{{ item.title }}</view>
  19. <view class="desc">{{ item.tdate }}</view>
  20. </view>
  21. <view class="select-box">
  22. <image v-if="selectedItem === item" src="../../static/icon/wd_icon_gouxuan05.png"></image>
  23. <image v-else src="../../static/icon/wd_icon_gouxuan04.png"></image>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. components: {},
  32. data() {
  33. return {
  34. skey: '',
  35. uinfo: {},
  36. selectedItem: null,
  37. listItems: []
  38. }
  39. },
  40. onLoad(params) {
  41. if (getApp().globalData.skey != "") {
  42. this.skey = getApp().globalData.skey;
  43. } else {
  44. this.skey = params.skey || ''; //1234567xef
  45. }
  46. this.id = params.id || '117';
  47. let that = this;
  48. that.getInfo();
  49. },
  50. onShow() {
  51. let that = this;
  52. },
  53. methods: {
  54. goBack() {
  55. uni.navigateBack(); // 返回上一页
  56. },
  57. selectItem(item) { // 添加选择项目的方法
  58. this.selectedItem = item;
  59. },
  60. onSubmit() {
  61. if (this.selectedItem) {
  62. uni.$emit('selectItem', this.selectedItem);
  63. uni.navigateBack(); // 返回上一页
  64. } else {
  65. uni.showToast({
  66. title: '请选择一个项目',
  67. icon: 'none'
  68. });
  69. }
  70. },
  71. getInfo() {
  72. var that = this;
  73. uni.request({
  74. url: this.$apiHost + '/Work/getlist', //仅为示例,并非真实接口地址。
  75. data: {
  76. uuid: getApp().globalData.uuid,
  77. id: this.id,
  78. type: "select"
  79. },
  80. header: {
  81. 'content-type': 'application/json' //自定义请求头信息
  82. },
  83. success: (res) => {
  84. console.log('获取到作品信息列表', res.data.list);
  85. this.listItems = res.data.list;
  86. }
  87. });
  88. },
  89. checkField(str, tips) {
  90. if (str.length < 2) {
  91. uni.showToast({
  92. title: tips,
  93. icon: 'none'
  94. });
  95. return false;
  96. }
  97. return true;
  98. },
  99. }
  100. }
  101. </script>
  102. <style scoped lang="scss">
  103. page {
  104. position: absolute;
  105. left: 0;
  106. top: 0;
  107. width: 100%;
  108. display: flex;
  109. background-color: #f2f6f2;
  110. min-height: 100vh;
  111. }
  112. .status_bar {
  113. height: 44rpx;
  114. width: 100%;
  115. }
  116. .page {
  117. background-color: #f2f6f2;
  118. display: flex;
  119. flex-direction: column;
  120. width: 750rpx;
  121. min-height: 100vh;
  122. }
  123. .nav-bar {
  124. width: calc(100ve - 73rpx);
  125. height: calc(96rpx + var(--status-bar-height));
  126. display: flex;
  127. align-items: center;
  128. justify-content: space-between;
  129. padding: 0;
  130. padding-right: 40rpx;
  131. padding-left: 33rpx;
  132. box-sizing: border-box;
  133. .left {
  134. display: flex;
  135. align-items: center;
  136. font-family: PingFang SC-Bold;
  137. font-weight: 400;
  138. font-size: 32rpx;
  139. color: #1f1f1f;
  140. .uni-btn-icon {
  141. font-size: 45rpx;
  142. font-weight: bold;
  143. color: #1f1f1f;
  144. transition: color 0.2s;
  145. margin-right: 20rpx;
  146. &:active {
  147. color: #2b85e4;
  148. }
  149. }
  150. }
  151. .center {
  152. font-size: 36rpx;
  153. font-family: "PingFang SC-Bold";
  154. font-weight: 400;
  155. color: #1f1f1f;
  156. }
  157. .right {
  158. display: flex;
  159. align-items: center;
  160. font-size: 28rpx;
  161. font-family: "PingFang SC-Bold";
  162. font-weight: 400;
  163. .btn {
  164. border-radius: 26rpx;
  165. background: #1f1f1f;
  166. padding: 6rpx 32rpx;
  167. color: #acf934;
  168. font-size: 28rpx;
  169. }
  170. }
  171. }
  172. .listContent {
  173. padding: 20rpx;
  174. display: grid;
  175. grid-template-columns: repeat(1, 1fr);
  176. row-gap: 20rpx;
  177. image {
  178. width: 100%;
  179. height: 100%;
  180. }
  181. .list-item {
  182. background: #fff;
  183. height: 220rpx;
  184. border-radius: 20rpx;
  185. padding: 22rpx 48rpx 22rpx 26rpx;
  186. box-sizing: border-box;
  187. display: flex;
  188. justify-content: space-between;
  189. .img-box {
  190. width: 130rpx;
  191. height: 166rpx;
  192. border-radius: 15rpx;
  193. overflow: hidden;
  194. }
  195. .info {
  196. width: 450rpx;
  197. height: 100%;
  198. display: flex;
  199. flex-direction: column;
  200. justify-content: space-between;
  201. padding: 10rpx;
  202. .title {
  203. font-weight: 400;
  204. font-size: 32rpx;
  205. color: #1F1F1F;
  206. }
  207. .desc {
  208. font-family: 'PingFang SC-Medium';
  209. font-weight: 400;
  210. font-size: 28rpx;
  211. color: #999999;
  212. }
  213. }
  214. .select-box {
  215. width: 40rpx;
  216. height: 100%;
  217. display: flex;
  218. justify-content: center;
  219. align-items: center;
  220. image {
  221. width: 40rpx;
  222. height: 40rpx;
  223. }
  224. }
  225. }
  226. }
  227. </style>