| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- // package-basic-data/pages/share-power/share-power.js
- const Constants = require('@/utils/Constants.js');
- const mixins = require('@/mixins/index.js');
- const app = getApp()
- const util = require('@/utils/util.js')
- const api = require('@/utils/api.js');
- Page({
- mixins: [mixins],
- /**
- * 页面的初始数据
- */
- data: {
- needHelpUserNumber: 5,
- powerModelShowFlag: true,
- menuButtonTop: 48,
- helpUserNumber: 0,
- params: {},
- helpFlag: true
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- const userNum = Number(options.userNum)
- options.receiveUser = options.userIdForm
- this.setData({
- params: options,
- needHelpUserNumber: userNum,
- })
- wx.hideShareMenu()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.showPowerModel()
- this.getSystemButtonLocation()
- this.getHelpUserNumber()
- },
- /**
- * @desc : 获取当前链接有多少人助力
- * @date : 2024/7/31 13:49
- * @author : 刘尧
- */
- getHelpUserNumber() {
- const params = this.data.params
- let service = app.globalData['couponReceiveService']
- this.excute(service, 'get_receive_user_number', params).then(res => {
- this.setData({
- helpUserNumber: res.data.data
- })
- })
- },
- /**
- * @desc : 页面加载时获取返回按钮距上边距
- * @date : 2024/7/31 13:49
- * @author : 刘尧
- */
- getSystemButtonLocation() {
- const res = wx.getMenuButtonBoundingClientRect()
- this.setData({
- menuButtonTop: res.top
- })
- },
- /**
- * @desc : 获取微信派发的临时登录凭证
- * @date : 2022/5/12 13:49
- * @author : 姜永辉
- */
- wxlogin() {
- return new Promise((resolve, reject) => {
- // 登录
- wx.login({
- success: res => {
- // 发送 res.code 到后台换取 openId, sessionKey, unionId
- console.log("wx.login", res);
- if (res.code) {
- resolve(res)
- } else {
- reject(res)
- }
- }
- })
- })
- },
- /**
- * @desc : 登录
- * @date : 2022/5/12 13:49
- * @author : 姜永辉
- */
- wx_login() {
- let _this = this
- _this.wxlogin().then(res => {
- _this.getopenid({ code: res.code });
- })
- },
- /**
- * @desc : 打开助力弹窗
- * @author : 刘尧
- * @date : 2024/7/29 09:26
- */
- showPowerModel() {
- this.setData({
- powerModelShowFlag: true
- })
- },
- /**
- * @desc : 跳转了解软件
- * @author : 刘尧
- * @date : 2024/7/29 09:26
- */
- toUnderstand(){
- let toUrl = '/package-basic-data/pages/understand-software/understand-software'
- wx.navigateTo({
- url: toUrl,
- })
- },
- /**
- * @desc : 跳转Welcome
- * @author : 刘尧
- * @date : 2024/8/5 09:26
- */
- wantToApp(){
- let toUrl = '/pages/welcome/welcome'
- wx.navigateTo({
- url: toUrl,
- })
- },
- /**
- * @desc : 获取微信派发的 openid
- * @date : 2022/5/12 13:49
- * @author : 姜永辉
- */
- getopenid(param) {
- return api.request(Constants.SYS_OPENID_API + 'oauth/wx/login_wechat', 'POST', param)
- },
- /**
- * @desc : 关闭小程序
- * @author : 刘尧
- * @date : 2024/7/29 09:49
- */
- closeMiniProgram() {
- wx.exitMiniProgram({
- success: function () {
- console.log('关闭小程序触发');
- }
- })
- },
- /**
- * @desc : 助力点击
- * @author : 刘尧
- * @date : 2024/7/31 11:11
- */
- helpMe() {
- let _this = this
- _this.wxlogin().then(res => {
- _this.getopenid({ code: res.code }).then(res => {
- if (res.data.code == Constants.SUCESS_CODE) {
- const openid = res.data.data.openid
- let service = app.globalData['couponReceiveService']
- const params = _this.data.params
- params.userWxid = openid
- _this.excute(service, 'insert_coupon_send', params).then(res => {
- if (res.data.code == Constants.SUCESS_CODE) {
- util.showToast('助力成功!')
- this.setData({
- helpUserNumber: this.data.helpUserNumber + 1
- })
- }
- this.setData({
- helpFlag: false,
- powerModelShowFlag: false
- })
- })
- }
- })
- })
- },
- /**
- * @desc : 打开助力弹窗
- * @author : 刘尧
- * @date : 2024/7/29 09:26
- */
- closePowerModel() {
- this.setData({
- powerModelShowFlag: false
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|