金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

235 lines
8.0 KiB

  1. <template>
  2. <view id="sign">
  3. <view class="sign_head">
  4. <view class="user_picture">
  5. <image :src="userImg" mode="" v-if="userImg"></image>
  6. <image v-else src="https://ibrand-miniprogram.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%A4%B4%E5%83%8F_%E7%94%BB%E6%9D%BF%201.png" />
  7. </view>
  8. <view class="sign_message">
  9. <view class="user_name">{{userName}}</view>
  10. <view class="user_message">
  11. <view class="fs_12" style="width:100px">积分{{point}}</view>
  12. <view @tap="sign_rule" class="fs_10 activity_rule">活动规则</view>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="sign_box">
  17. <view class="sign_body">
  18. <view class="row_first">
  19. <view class="sign_bar_single"></view>
  20. <view v-for="(item,index) in rules" :key="index" class="row_box">
  21. <view :class="days < 7 ?'sign_bar':'sign_afterBar'" v-if="index ==7"></view>
  22. <view :class="days < 14 ?'sign_bar':'sign_afterBar'" v-if="index == 14"></view>
  23. <view style="width:57.5rpx;position:relative">
  24. <view class="sign_gift" v-if="index == 6 || index == 13 || index == 20" @tap='getGift'>
  25. <view class="angel"></view>
  26. <image src="../../../static/gift.png"/>
  27. </view>
  28. <view :class="index+1>days ?'sign_point_false':'sign_point'">
  29. <text>+{{item}}</text>
  30. </view>
  31. <view class="iconfont icon-check-circle signed_today" v-if="is_sign && days==index+1"></view>
  32. <view class="sign_day">{{item}}</view>
  33. </view>
  34. <view :class="index+1>days ?'sign_bar':'sign_afterBar'" v-if="index<20"></view>
  35. </view>
  36. </view>
  37. <view class="signed_days color" v-if="!is_sign" @tap="sign">今日签到
  38. </view>
  39. <view class="signed_days" v-if="is_sign">已连续签到 <text>{{days}}</text>
  40. </view>
  41. <view class="sign_data">
  42. <view @tap="signData">签到记录 </view>
  43. <view style="margin-left:6rpx">></view><text class="arrows" style="padding-left:5px">></text>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="image_box">
  48. <view :class="'img'+index" v-for="(item,index) in microData.data.pages" :key="index" :style="'background:'+item.meta.background_color">
  49. <image :src="item.value[0].image" mode="aspectFit" v-if="index!=2 && index!==4" />
  50. <image :src="item.value[0].image" mode="aspectFit" v-if="index==2 && index!==4" />
  51. <view v-if="index==4">
  52. <indexGrouping :grouping-data="item.value" :meta="item.meta"></indexGrouping>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="mask_form" v-if="show" @tap="close" catchtouchmove="true">
  57. <view class="rule_box">
  58. <text class="mask" decode="decode">
  59. {{rule}}
  60. </text>
  61. <view bindtap="close" class="close_rule">
  62. <i class="iconfont icon-close"></i>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. var app = getApp();
  70. import {pageLogin, getUrl} from '@/common/js/utils.js';
  71. import indexGrouping from "@/components/index-grouping/index-grouping.vue"
  72. export default {
  73. data() {
  74. return {
  75. point: '',
  76. text: "This is page data",
  77. signId: '',
  78. action: [],
  79. recommend_goods: [],
  80. days:0,
  81. nodes: '',
  82. microData:{
  83. data:{
  84. pages:[]
  85. }
  86. },
  87. index: 0,
  88. userImg: '',
  89. userName: '',
  90. rule: '',
  91. show:false,
  92. rules:[],
  93. is_sign:''
  94. };
  95. },
  96. components:{
  97. indexGrouping
  98. },
  99. watch:{
  100. microData:{
  101. deep:true,
  102. handler(val){
  103. this.microData=val
  104. }
  105. }
  106. },
  107. methods:{
  108. // 签到
  109. sign(){
  110. wx.showLoading({
  111. title: '正在签到',
  112. mask: true
  113. });
  114. this.$http.post({
  115. api: "api/sign/doSign",
  116. data: {
  117. sign_id: this.signId
  118. },
  119. header: {
  120. Authorization: this.$cookieStorage.get('user_token')
  121. },
  122. }).then(res => {
  123. if (res.statusCode == 200) {
  124. res = res.data;
  125. if (res.status) {
  126. wx.showModal({
  127. content: res.data.message || "签到成功",
  128. showCancel: false,
  129. success: res => {
  130. if (res.confirm || (!res.cancel && !res.confirm)) {
  131. this.record(); //签到成功重新请求数据
  132. }
  133. }
  134. })
  135. } else {
  136. wx.showModal({
  137. content: res.message || '签到失败',
  138. showCancel: false
  139. })
  140. }
  141. } else {
  142. wx.showModal({
  143. content: res.message || "请求失败",
  144. showCancel: false
  145. })
  146. }
  147. wx.hideLoading();
  148. }).catch(res => {
  149. wx.hideLoading();
  150. wx.showModal({
  151. content: '请求失败',
  152. showCancel: false
  153. })
  154. })
  155. },
  156. // 签到记录
  157. signData() {
  158. wx.navigateTo({
  159. url: "/pages/user/signData/signData"
  160. })
  161. },
  162. record() {
  163. this.$http.get({
  164. api: 'api/sign/getSignReward',
  165. header: {
  166. Authorization: this.$cookieStorage.get('user_token')
  167. }
  168. }).then(res => {
  169. if (res.statusCode == 200) {
  170. this.point= res.data.data.point,
  171. this.signId=res.data.data.sign.id,
  172. this.action=res.data.data.sign.action, //数组
  173. this.rules= res.data.data.sign.rules,
  174. this.recommend_goods= res.data.data.sign.recommend_goods,
  175. this.days= res.data.data.sign.days, //修改item
  176. this.nodes= res.data.data.sign.rule_desc,
  177. this.is_sign= res.data.data.is_sign,
  178. this.rule= res.data.data.sign_rule
  179. console.log("signId",this.signId)
  180. }
  181. }).catch(rej => {
  182. console.log(rej);
  183. })
  184. this.userImg= this.$cookieStorage.get('userInfoImg'),
  185. this.userName= this.$cookieStorage.get('userInfoName')
  186. wx.hideLoading()
  187. },
  188. // 礼物
  189. getGift() {
  190. console.log("gift");
  191. },
  192. integral() {
  193. this.$http.get({
  194. api: 'api/micro/page/Integral?name=Integral',
  195. }).then(res => {
  196. if (res.statusCode == 200) {
  197. this.microData=res.data
  198. console.log("microData.data.pages",this.microData.data.pages)
  199. console.log("this.microData",this.microData)
  200. }
  201. }).catch(rej => {
  202. console.log(rej);
  203. })
  204. },
  205. // 签到规则
  206. sign_rule() {
  207. this.show=true;
  208. },
  209. close(){
  210. this.show=false;
  211. },
  212. },
  213. // onLoad: function() {
  214. // wx.showLoading({
  215. // title: "加载中",
  216. // mask: true
  217. // });
  218. // this.record()
  219. // },
  220. created() {
  221. this.record()
  222. },
  223. onShow: function() {
  224. this.integral()
  225. }
  226. }
  227. </script>
  228. <style lang="less">
  229. @import "sign.less";
  230. </style>