index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <!--
  2. 广告宣传 - 卡片页
  3. http://localhost:5173/card/#/pages/ad/index
  4. https://oss-mbh5.colormaprun.com/card/#/pages/ad/index
  5. -->
  6. <template>
  7. <view class="body body-radius">
  8. <view v-if="pageReady" class="content content-bg" @click="btnClick">
  9. <view class="card-top uni-row">
  10. <!-- <view class="top-right uni-row">
  11. <image mode="aspectFit" class="clock" src="/static/default/clock.png"></image>
  12. <view class="countdown">{{countdown}}</view>
  13. </view> -->
  14. </view>
  15. <view class="card-main uni-column">
  16. <view class="logo"></view>
  17. <view class="uni-row" style="position: relative;">
  18. <!-- <image v-if="notice" mode="aspectFit" src="/static/common/notice.png" class="notice"></image> -->
  19. <text v-if="type != ''" class="type mod-text">{{type}}</text>
  20. </view>
  21. <view v-if="ecName != ''" class="name mod-text">{{ecName}}</view>
  22. <button v-if="btnText != ''" class="button mod-button">{{btnText}}</button>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import tools from '/common/tools';
  29. import cardfunc from '/common/cardfunc';
  30. import {
  31. localCardConfig
  32. } from "./cardconfig/test.js";
  33. import {
  34. token,
  35. ossUrl,
  36. apiCardBaseQuery
  37. } from '/common/api';
  38. export default {
  39. data() {
  40. return {
  41. cardConfigData: cardfunc.cardConfigData,
  42. pageReady: false,
  43. pageName: "index",
  44. queryObj: {},
  45. queryString: "",
  46. token: "",
  47. cardconfig: {}, // 卡片配置
  48. ecId: 0, // 卡片id
  49. ecName: '', // 卡片名称
  50. ecDesc: '', // 卡片简介
  51. beginSecond: null, // 卡片开始时间戳,单位秒
  52. endSecond: null, // 卡片结束时间戳,单位秒
  53. // secondCardName: '', // 跳转页面名称
  54. type: "",
  55. btnText: "",
  56. notice: false, // 是否显示(小红点)通知图标
  57. }
  58. },
  59. computed: {},
  60. onLoad(query) { // 类型非必填,可自动推导
  61. // console.log(query);
  62. this.queryObj = query;
  63. this.queryString = tools.objectToQueryString(this.queryObj);
  64. // console.log(queryString);
  65. this.token = query["token"] ?? token;
  66. this.ecId = query["id"] ?? 0;
  67. this.type = query["type"] ?? "";
  68. this.btnText = query["btnText"] ?? "";
  69. cardfunc.init(this, this.token, this.ecId);
  70. cardfunc.getCardConfig(this.cardConfigQueryCallback, localCardConfig);
  71. this.getCardBaseQuery();
  72. },
  73. onShow() {},
  74. onUnload() {
  75. },
  76. methods: {
  77. cardConfigQueryCallback(cardconfig) {
  78. this.cardconfig = cardconfig;
  79. this.loadCardConfig(this.cardconfig);
  80. this.pageReady = true;
  81. },
  82. loadCardConfig(cardconfig) {
  83. cardconfig = cardfunc.parseCardConfig(cardconfig);
  84. // console.log("[loadCardConfig] cardconfig:", cardconfig);
  85. // 加载卡片通用配置
  86. if (cardconfig.common != undefined) {
  87. cardfunc.loadCardCommonConfig(cardconfig.common);
  88. }
  89. // -------- 加载当前页面的配置 --------
  90. const config = cardfunc.parseCardConfig(cardconfig[this.pageName]);
  91. // console.log("[loadConfig] config_page:", config);
  92. if (config == undefined || config == null) {
  93. return;
  94. }
  95. // 加载CSS样式
  96. const css = config.css;
  97. if (css != undefined && css.length > 0) {
  98. tools.loadCssCode(css);
  99. }
  100. },
  101. // 卡片基本信息查询
  102. getCardBaseQuery() {
  103. uni.request({
  104. url: apiCardBaseQuery,
  105. header: {
  106. "Content-Type": "application/x-www-form-urlencoded",
  107. "token": this.token,
  108. },
  109. method: "POST",
  110. data: {
  111. ecId: this.ecId,
  112. pageName: this.pageName
  113. },
  114. success: (res) => {
  115. // console.log("getCardBaseQuery", res)
  116. const data = res.data.data;
  117. this.ecName = data.ecName;
  118. this.ecDesc = data.ecDesc;
  119. this.beginSecond = data.beginSecond;
  120. this.endSecond = data.endSecond;
  121. // this.secondCardName = data.secondCardName;
  122. },
  123. fail: (err) => {
  124. console.log("getCardBaseQuery err", err)
  125. },
  126. });
  127. },
  128. btnClick() {
  129. const url = `${ossUrl}#/pages/ad/detail?${this.queryString}&full=true`;
  130. tools.appAction(url);
  131. }
  132. }
  133. }
  134. </script>
  135. <style scoped>
  136. .content {
  137. width: 100vw;
  138. height: 100vh;
  139. }
  140. .content-bg {
  141. background: linear-gradient(180deg, #7aedff 0%, #047200 100%);
  142. /* background: linear-gradient(180deg, #178bff 0%, #004d9b 100%); */
  143. /* background: linear-gradient(180deg, #7aedff 0%, #8d2219 100%); */
  144. }
  145. .card-top {
  146. width: 100%;
  147. justify-content: flex-end;
  148. }
  149. .top-right {
  150. min-width: 180rpx;
  151. height: 80rpx;
  152. margin-top: 30rpx;
  153. margin-right: 30rpx;
  154. padding-left: 16rpx;
  155. padding-right: 16rpx;
  156. background-color: rgba(0, 0, 0, 0.3);
  157. border-radius: 12px;
  158. }
  159. .clock {
  160. width: 50rpx;
  161. height: 50rpx;
  162. margin-right: 12rpx;
  163. }
  164. .countdown {
  165. min-width: 120rpx;
  166. text-align: center;
  167. font-family: Roboto;
  168. color: #ffffff;
  169. font-size: 46rpx;
  170. /* letter-spacing: 2rpx; */
  171. }
  172. .card-main {
  173. width: 100%;
  174. /* height: 700rpx; */
  175. height: 660rpx;
  176. margin-top: 20rpx;
  177. justify-content: space-evenly;
  178. }
  179. .logo {
  180. width: 50vw;
  181. height: 50vw;
  182. /* background-image: var(--default-matchLogo-url); */
  183. background-repeat: no-repeat;
  184. background-position-x: center;
  185. background-position-y: center;
  186. background-size: contain;
  187. }
  188. .notice {
  189. width: 30rpx;
  190. height: 30rpx;
  191. /* margin-right: 30rpx; */
  192. position: absolute;
  193. left: -60rpx;
  194. }
  195. .type {
  196. opacity: 60%;
  197. /* line-height: 25px; */
  198. font-family: Roboto;
  199. color: #ffffff;
  200. font-size: 40rpx;
  201. text-align: center;
  202. }
  203. .name {
  204. font-family: Roboto;
  205. color: #ffffff;
  206. font-size: 50rpx;
  207. text-align: center;
  208. }
  209. .button {
  210. width: 320rpx;
  211. height: 86rpx;
  212. margin-top: 30rpx;
  213. color: #000000;
  214. background: #ffffff;
  215. border-radius: 56rpx;
  216. font-size: 46rpx;
  217. line-height: 80rpx;
  218. }
  219. </style>