relatedWorks.vue 4.5 KB

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