relatedWorks.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. padding-top: var(--status-bar-height);
  133. box-sizing: border-box;
  134. .left {
  135. display: flex;
  136. align-items: center;
  137. font-family: PingFang SC-Bold;
  138. font-weight: 400;
  139. font-size: 32rpx;
  140. color: #1f1f1f;
  141. .uni-btn-icon {
  142. font-size: 45rpx;
  143. font-weight: bold;
  144. color: #1f1f1f;
  145. transition: color 0.2s;
  146. margin-right: 20rpx;
  147. &:active {
  148. color: #2b85e4;
  149. }
  150. }
  151. }
  152. .center {
  153. font-size: 36rpx;
  154. font-family: "PingFang SC-Bold";
  155. font-weight: 400;
  156. color: #1f1f1f;
  157. }
  158. .right {
  159. display: flex;
  160. align-items: center;
  161. font-size: 28rpx;
  162. font-family: "PingFang SC-Bold";
  163. font-weight: 400;
  164. .btn {
  165. border-radius: 26rpx;
  166. background: #1f1f1f;
  167. padding: 6rpx 32rpx;
  168. color: #acf934;
  169. font-size: 28rpx;
  170. }
  171. }
  172. }
  173. .listContent {
  174. padding: 20rpx;
  175. display: grid;
  176. grid-template-columns: repeat(1, 1fr);
  177. row-gap: 20rpx;
  178. image {
  179. width: 100%;
  180. height: 100%;
  181. }
  182. .list-item {
  183. background: #fff;
  184. height: 220rpx;
  185. border-radius: 20rpx;
  186. padding: 22rpx 48rpx 22rpx 26rpx;
  187. box-sizing: border-box;
  188. display: flex;
  189. justify-content: space-between;
  190. .img-box {
  191. width: 130rpx;
  192. height: 166rpx;
  193. border-radius: 15rpx;
  194. overflow: hidden;
  195. }
  196. .info {
  197. width: 450rpx;
  198. height: 100%;
  199. display: flex;
  200. flex-direction: column;
  201. justify-content: space-between;
  202. padding: 10rpx;
  203. .title {
  204. font-weight: 400;
  205. font-size: 32rpx;
  206. color: #1F1F1F;
  207. }
  208. .desc {
  209. font-family: 'PingFang SC-Medium';
  210. font-weight: 400;
  211. font-size: 28rpx;
  212. color: #999999;
  213. }
  214. }
  215. .select-box {
  216. width: 40rpx;
  217. height: 100%;
  218. display: flex;
  219. justify-content: center;
  220. align-items: center;
  221. image {
  222. width: 40rpx;
  223. height: 40rpx;
  224. }
  225. }
  226. }
  227. }
  228. </style>