index.ux 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <!-- src/components/tools-mall/index.ux -->
  2. <template>
  3. <div class="content">
  4. <div class="box text-white">
  5. <text class="text-24 text-white" style="font-size: 24px;">金币明细</text>
  6. <div class="mgy-20" style="align-items: center;">
  7. <text class="text-48 text-white" style="margin-right: 5px;font-size: 48px;">{{ coinNum }}</text>
  8. <text class="text-white" style="font-size: 24px;margin-left: 10px;" @click="navTo('pages/commonModule/coinRecord')">金币 ></text>
  9. </div>
  10. <text class="text-24 text-white" style="font-size: 24px;">活动奖品数量有限,先到先得,兑完即止</text>
  11. </div>
  12. <div class="box2">
  13. <div class="top_box">
  14. <text class="text-36" style="color: #333;">新人签到 必得金币</text>
  15. <text class="text-24" style="color: #ffcdaf;margin-top: 10px;">活动盛启,福利满满</text>
  16. </div>
  17. <div class="bottom_box">
  18. <div class="bottom_item" style="border-bottom: 1px solid #ddd;">
  19. <div class="fd_c">
  20. <text class="text-32 text-000">签到</text>
  21. <text class="text-24 text-999">连续签到奖励更高!</text>
  22. </div>
  23. <div class="{{ signStatus?'disBtn':'btn' }}" @click="signIn">
  24. <text>{{ signStatus ? '已签到' : '签到'}}</text>
  25. </div>
  26. </div>
  27. <div class="bottom_item" style="border-bottom: 1px solid #ddd;">
  28. <div class="fd_c">
  29. <text class="text-32 text-000">天天惊喜,红包多多</text>
  30. <text class="text-24 text-999">金币兑换海量福利等你来拿</text>
  31. </div>
  32. <div class="{{ getStatus?'disBtn':'btn' }}" @click="getCoin">
  33. <text>{{getStatus?'已领取':'立即领取'}}</text>
  34. </div>
  35. </div>
  36. <div style="height: 300px;width: 100%;">
  37. <ad
  38. adId="{{adList.adId}}"
  39. class="ad-native"
  40. style="height: 100%;width: 100%;"
  41. if="{{adList && adList.adId}}"
  42. >
  43. <div class="container">
  44. <block>
  45. <div class="vertical-content big-img">
  46. <ad-clickable-area type="click" class="ad-image" if="{{ adList.creativeType===2}}">
  47. <image src="{{adList.imgUrlList[0]}}" style="width: 100%;"></image>
  48. </ad-clickable-area>
  49. <!-- <div class="ad-text">
  50. <ad-clickable-area type="click">
  51. <text>{{ adList.desc }}</text>
  52. </ad-clickable-area>
  53. </div> -->
  54. </div>
  55. </block>
  56. <div class="footer">
  57. <ad-clickable-area type="click" class="footer-info">
  58. <image class="tag" src="{{adList.icon}}"></image>
  59. <text class="title">{{ adList.title }}</text>
  60. </ad-clickable-area>
  61. <div class="click-item">
  62. <ad-clickable-area
  63. type="button"
  64. class="click-txt"
  65. value="{{ adList.clickBtnTxt }}"
  66. >
  67. </ad-clickable-area>
  68. </div>
  69. </div>
  70. </div>
  71. </ad>
  72. </div>
  73. <div class="bottom_item" style="border-bottom: 1px solid #ddd;">
  74. <div class="fd_c">
  75. <text class="text-32 text-000">柚趣屋</text>
  76. <text class="text-24 text-999">点击右边按钮体验</text>
  77. </div>
  78. <div class="btn" @click="backIndex()">
  79. <text>返回首页</text>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </template>
  86. <script>
  87. import router from '@system.router'
  88. export default {
  89. private: {
  90. coinNum:0,//金币数量
  91. signStatus:false, // 是否已经签到
  92. getStatus:false,// 是否已领取
  93. adUnitId: "d3d0539a806145ebabf502d29d0d1b43", // 这个id是vivo的com.quickapp.center创建的,需要修改manifest的package才能预览出效果
  94. ad: null,
  95. adList:{},
  96. },
  97. onInit() {
  98. // this.initAd()
  99. this.indexNativeAd()
  100. },
  101. indexNativeAd(){
  102. // 原生广告 1.0
  103. // let nativeAd = ad.createNativeAd({ // 使用require方式避免在不支持的广告接口的厂商运行是报错
  104. // adUnitId: '805a483bc3b14205a1d160cb97d0eca0',
  105. // })
  106. // nativeAd.onLoad((data) => {
  107. // console.log('Native ad resources!', data); // 广告加载成功,返回原生广告资源,根据但是资源自行渲染展现
  108. // })
  109. // nativeAd.load();
  110. // 原生广告2.0
  111. let adParams = {
  112. adUnitId: '805a483bc3b14205a1d160cb97d0eca0', // 原生广告2.0广告位id
  113. type: 'native', // 原生广告2.0广告类型
  114. adCount: 1, // 原生广告2.0广告预期返回广告条数
  115. }
  116. require('@service.ad').preloadAd({
  117. ...adParams,
  118. success: (data) => {
  119. this.adList = data.adList[0]
  120. console.log('data',data)
  121. // prompt.showToast({
  122. // message: `success! data=${JSON.stringify(data)}`
  123. // })
  124. }, fail: (data, code) => {
  125. console.log(data, code)
  126. // prompt.showToast({
  127. // message: `fail! data=${JSON.stringify(data)}, code=${code}`
  128. // })
  129. }
  130. })
  131. },
  132. backIndex() {
  133. router.replace({
  134. uri: 'pages/main',
  135. params: {
  136. testId: '1'
  137. }
  138. })
  139. },
  140. navTo(uri){
  141. router.push({
  142. uri,
  143. })
  144. },
  145. getCoin(){
  146. this.initAd()
  147. },
  148. initAd() {
  149. try {
  150. this.ad = require('@service.ad').createRewardedVideoAd({ // 使用require方式避免在不支持的广告接口的厂商运行是报错
  151. adUnitId: this.adUnitId,
  152. })
  153. this.ad.onLoad(() => {
  154. this.ad.show();
  155. })
  156. this.ad.onClose((res) => {
  157. if (res && res.isEnded) {
  158. console.log("正常播放结束,可以下发奖励");
  159. if(!this.getStatus){
  160. $utils.showToast('领取成功')
  161. this.coinNum += 10
  162. this.getStatus = true
  163. }else{
  164. $utils.showToast('已领取')
  165. }
  166. } else {
  167. console.log("播放中途退出,不下发奖励");
  168. }
  169. })
  170. this.ad.load();
  171. } catch (e) {
  172. console.log(e)
  173. }
  174. },
  175. signIn(){
  176. if(!this.signStatus){
  177. $utils.showToast('签到成功')
  178. this.coinNum += 10
  179. this.signStatus = true
  180. }else{
  181. $utils.showToast('已签到')
  182. }
  183. },
  184. }
  185. </script>
  186. <style lang="less">
  187. .content {
  188. padding: 28px;
  189. flex-direction: column;
  190. background: linear-gradient(to bottom, #ff8843, #ffffff);
  191. }
  192. .box {
  193. width: 100%;
  194. height: 220px;
  195. padding: 28px;
  196. background: linear-gradient(90deg, #ff7a3d, #ff582e);
  197. border-radius: 30px;
  198. flex-direction: column;
  199. }
  200. .text-white{
  201. color: #fff;
  202. }
  203. .mgy-20{
  204. margin: 20px 0;
  205. }
  206. .box2 {
  207. flex-direction: column;
  208. margin-top: 50px;
  209. border-radius: 30px;
  210. .top_box {
  211. height: 180px;
  212. background: linear-gradient(90deg, #ff843c, #ff6e6e);
  213. border-radius: 30px;
  214. flex-direction: column;
  215. padding: 30px;
  216. }
  217. .text-36{
  218. font-size: 36px;
  219. }
  220. .text-32{
  221. font-size: 32px;
  222. }
  223. .text-24{
  224. font-size: 24px;
  225. }
  226. .fd_c{
  227. flex-direction: column;
  228. }
  229. .text-000{
  230. color: #000;
  231. }
  232. .text-white{
  233. color: #fff;
  234. }
  235. .bottom_box {
  236. margin-top: -30px;
  237. border-radius: 30px;
  238. background-color: #ffffff;
  239. height: 600px;
  240. flex-direction: column;
  241. .bottom_item{
  242. justify-content: space-between;
  243. align-items: center;
  244. padding: 20px;
  245. }
  246. .disBtn{
  247. text{
  248. color: #999;
  249. font-size: 22px;
  250. }
  251. background-color: #ccc;
  252. height: 60px;
  253. line-height: 60px;
  254. width: 150px;
  255. justify-content: center;
  256. border-radius: 30px;
  257. }
  258. .btn {
  259. text{
  260. color: #ffffff;
  261. font-size: 22px;
  262. }
  263. background-color: #ff843c;
  264. height: 60px;
  265. line-height: 60px;
  266. width: 150px;
  267. justify-content: center;
  268. border-radius: 30px;
  269. }
  270. }
  271. }
  272. </style>