123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- // pages/status/status.js
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- type: 1,//1:有倒计时
- openId: '',
- target: '',//生成的连接
- url: '',//上级页面时二维码时,只需要有图片地址
- word: '',
- post: '',//上级页面是小程序,主图
- app_id: '',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- openId: wx.getStorageSync('userInfo').openId,
- url: options.url,
- word:wx.getStorageSync('introduce'),
- post:options.post,
- app_id:options.app_id,
- path:options.path
- })
- this.getUrl();
- },
- getUrl() {
- var info = wx.getStorageSync('shopInfo')
- var item = {};
- if(this.data.url) {
- item = {
- title: this.data.word,
- author: '👇👇👇',
- digest: '',
- content_source_url: '',
- thumb_url: this.data.url,
- content: ('<div style="text-align:center;"><img data-src="'+this.data.url+'" src="'+this.data.url+'" alt="" style="height:auto;"><div>↑↑ 长按上方识别二维码 ↑↑</div></div>')
- }
- }else {
- item = {
- title: wx.getStorageSync('word'),
- author: wx.getStorageSync('author'),
- digest: '',
- content_source_url: '',
- thumb_url: info.imageUrl
- }
- var infoObj = wx.getStorageSync('programObj')
- if(this.data.post) {
- item.thumb_url = this.data.post
- item.content = '<div class="shop" style="padding: 20px 12px;"><img data-cropselx1="0" data-cropselx2="400" data-cropsely1="0" data-cropsely2="400" data-ratio="1" data-s="300,640" style="width:calc(100vw - 24px);height: auto;" src="'+this.data.post+'" alt="" class="icon"><div class="info" style="display: flex;justify-content: space-between;line-height: 40px;margin: 10px 0;"><section style="width:100%;overflow:hidden;margin-bottom: 20px;background: #f7f7f7;height: 72px;border-radius: 2px;line-height: 50px;font-size: 17px;"><img class="rich_pages" data-cropselx1="0" data-cropselx2="400" data-cropsely1="0" data-cropsely2="400" data-ratio="1" data-s="300,640" data-w="800" data-src="'+infoObj.app_logo_url+'" style="border-radius: 50px; margin-top: 11px; margin-left: 13px; pointer-events: none; width: 50px!important; height: auto!important; visibility: visible !important;" src="'+infoObj.app_logo_url+'" alt="图片"><section style="display: flex;width: 70%;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;margin-top: -70px;margin-left: 76px;color:#434343;"><strong>'+infoObj.app_name+'</strong></section><a class="weapp_text_link js_weapp_entry" style="display:block;width:100%;line-height:72px;text-align: center;color:#fff;margin-top:-72px;opacity:0;" data-miniprogram-appid="'+this.data.app_id+'" data-miniprogram-path="'+this.data.path+'" href="" data-miniprogram-type="text" data-miniprogram-servicetype="">小程序跳转</a></section></div>'
- }else {
- item.content = '<div class="shop" style="padding: 20px 12px;"><img style="width:calc(100vw - 24px);height: auto;" src="'+info.imageUrl+'" alt="" class="icon"><div class="info" style="display: flex;justify-content: space-between;line-height: 40px;margin: 10px 0;"><div class="price" style="color: #ea445a;font-size: 14px;">券后¥<span>'+info.couponAfterPrice+'</span></div><div class="type">'+info.platform+'</div></div><div class="title" style="font-size: 17px;font-weight: bold;line-height: 30px;">'+info.skuName+'</div><div style="width:100%;height:40px;border-radius:6px;background:#EA445A;color:#fff;"><a class="weapp_text_link js_weapp_entry" style="display:block;line-height:40px;text-align: center;color:#fff;" data-miniprogram-appid="'+info.xcx_app_id+'" data-miniprogram-path="'+info.xcx_url+'" data-miniprogram-nickname="'+info.platform+'" href="" data-miniprogram-type="text" data-miniprogram-servicetype="">小程序跳转</a></div></div>'
- }
- }
- this.setData({
- type: 1
- })
- app.func.req('/api/goods/resourceUrl', 'post', {
- 'article': item,
- 'openid': this.data.openId
- }, (res) => {
- wx.hideLoading()
- if(res && res.errno == 0){
- if(!res.rst.url) {
- this.setData({
- type: 3
- })
- wx.showToast({
- title: '链接生成错误',
- icon: 'none'
- })
- return;
- }
- //成功
- this.setData({
- target: res.rst.url,
- type: 2
- })
- }else {
- this.setData({
- type: 3
- })
- wx.showToast({
- title: res.err,
- icon: 'none'
- })
- }
- },()=>{
- wx.hideLoading()
- })
- },
- // 返回上个页面不刷新
- toBack() {
- if(this.data.url) {
- wx.redirectTo ({
- url: '/pages/qrcode/qrcode'
- })
- return;
- }else if(this.data.post) {
- wx.redirectTo({
- url: '/pages/applet/applet'
- })
- return;
- }
- wx.redirectTo ({
- url: '/pages/link/index'
- })
- },
- copy() {
- console.log(this.data.target)
- wx.setClipboardData({
- data: this.data.target
- })
- },
- onShareAppMessage() {
-
- }
- })
|