123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- const app = getApp();
- const api = require('../../api/api');
- Page({
-
- data: {
- navbarData: {
- showCapsule: 1,
- title: '分享朋友圈',
- capsuleMode: 'navBack',
- },
- news: [
- '生鲜', '教育', '熟食', '生鲜', '甜点糕点', '生活用品', '教育'
- ],
- type: 0,
- id: 0,
- user_info: {},
- classification_info: [],
- info: {},
- pintuan_detail: {},
- },
-
- onLoad(options) {
- let that = this;
- that.setData({
- type: Number(options.type),
- id: Number(options.id)
- })
- if (that.data.type == 0) {
-
- that.getHead_info();
- } else if (that.data.type == 1) {
-
- that.getCode_gang();
- }
- },
-
- onReady() {
- },
-
- onShow() {
- },
-
- onHide() {
- },
-
- onUnload() {
- },
-
- onPullDownRefresh() {
- },
-
- onReachBottom() {
- },
-
- onShareAppMessage() {
- },
- getHead_info() {
- let that = this;
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: api.Head_info,
- header: {
- 'Authorization': wx.getStorageSync('token')
- },
- data: {
- id: that.data.id
- },
- success(res) {
- wx.hideLoading()
- console.log(res);
- if (res.data.code === 1) {
- that.setData({
- user_info: res.data.data.user_info,
- classification_info: res.data.data.classification_info,
- info: res.data.data.info
- })
- } else {
- wx.showToast({
- title: res.data.msg,
- mask: true,
- icon: 'none'
- })
- }
- },
- fail(err) {
- wx.hideLoading()
- wx.showToast({
- title: '发起网络请求失败',
- icon: 'none',
- mask: true
- })
- },
- complete() {
-
- }
- })
- },
- getCode_gang() {
- let that = this;
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: api.Code_gang,
- header: {
- 'Authorization': wx.getStorageSync('token')
- },
- data: {
- id: that.data.id
- },
- success(res) {
- wx.hideLoading()
- console.log(res);
- if (res.data.code === 1) {
- that.setData({
- pintuan_detail: res.data.data
- })
- } else {
- wx.showToast({
- title: res.data.msg,
- mask: true,
- icon: 'none'
- })
- }
- },
- fail(err) {
- wx.hideLoading()
- wx.showToast({
- title: '发起网络请求失败',
- icon: 'none',
- mask: true
- })
- },
- complete() {
-
- }
- })
- },
-
- downloadImg() {
- wx.showLoading({
- title: '加载中...'
- });
-
- wx.downloadFile({
- url: this.data.user_info.wechat_code,
- success: function (res) {
-
- wx.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success: function (data) {
- wx.hideLoading();
- wx.showModal({
- title: '提示',
- content: '保存成功',
- modalType: false,
- })
- },
-
- fail: function (err) {
- if (err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" || err.errMsg === "saveImageToPhotosAlbum:fail auth deny" || err.errMsg === "saveImageToPhotosAlbum:fail authorize no response") {
- wx.showModal({
- title: '提示',
- content: '需要您授权保存相册',
- modalType: false,
- success: modalSuccess => {
- wx.openSetting({
- success(settingdata) {
- console.log("settingdata", settingdata)
- if (settingdata.authSetting['scope.writePhotosAlbum']) {
- wx.showModal({
- title: '提示',
- content: '获取权限成功,再次点击图片即可保存',
- modalType: false,
- })
- } else {
- wx.showModal({
- title: '提示',
- content: '获取权限失败,将无法保存到相册哦~',
- modalType: false,
- })
- }
- },
- fail(failData) {
- console.log("failData", failData)
- },
- complete(finishData) {
- console.log("finishData", finishData)
- }
- })
- }
- })
- }
- },
- complete(res) {
- wx.hideLoading();
- }
- })
- }
- })
- },
-
- downloadImg2() {
- wx.showLoading({
- title: '加载中...'
- });
-
- wx.downloadFile({
- url: this.data.pintuan_detail.gang_code,
- success: function (res) {
-
- wx.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success: function (data) {
- wx.hideLoading();
- wx.showModal({
- title: '提示',
- content: '保存成功',
- modalType: false,
- })
- },
-
- fail: function (err) {
- if (err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" || err.errMsg === "saveImageToPhotosAlbum:fail auth deny" || err.errMsg === "saveImageToPhotosAlbum:fail authorize no response") {
- wx.showModal({
- title: '提示',
- content: '需要您授权保存相册',
- modalType: false,
- success: modalSuccess => {
- wx.openSetting({
- success(settingdata) {
- console.log("settingdata", settingdata)
- if (settingdata.authSetting['scope.writePhotosAlbum']) {
- wx.showModal({
- title: '提示',
- content: '获取权限成功,再次点击图片即可保存',
- modalType: false,
- })
- } else {
- wx.showModal({
- title: '提示',
- content: '获取权限失败,将无法保存到相册哦~',
- modalType: false,
- })
- }
- },
- fail(failData) {
- console.log("failData", failData)
- },
- complete(finishData) {
- console.log("finishData", finishData)
- }
- })
- }
- })
- }
- },
- complete(res) {
- wx.hideLoading();
- }
- })
- }
- })
- }
- })
|