|
@@ -1,6 +1,107 @@
|
|
|
var sceneReadyBehavior = require('../../behavior-scene/scene-ready');
|
|
|
+
|
|
|
Page({
|
|
|
behaviors:[sceneReadyBehavior],
|
|
|
+ data:{
|
|
|
+ captureState: 0,
|
|
|
+ recordState: 0,
|
|
|
+ captureQuality: 0.8,
|
|
|
+ captureType: 'jpg',
|
|
|
+ recordFPS: 30,
|
|
|
+ recordScale: 1,
|
|
|
+ recordWidth: 0,
|
|
|
+ recordHeight: 0,
|
|
|
+ recordBPS: 30000,
|
|
|
+ sceneWidth: 0,
|
|
|
+ sceneHeight: 0,
|
|
|
+
|
|
|
+ zhaohuanstate:true,
|
|
|
+ paizhaostate:false,
|
|
|
+ luxiangstate:false,
|
|
|
+ isStartluxiang:true,
|
|
|
+ isCloseluxiang:false,
|
|
|
+
|
|
|
+ uiShowModelView:false,
|
|
|
+ UiShowModel_Bottom:false,
|
|
|
+ uiMainView:true,
|
|
|
+ uiShowNum:3,
|
|
|
+ uiShowIndex:0,
|
|
|
+
|
|
|
+ current:0,
|
|
|
+ products:[],
|
|
|
+ modelImg:[
|
|
|
+ 'https://wx-model-1317557471.cos.ap-shanghai.myqcloud.com/WXImage/%E9%80%89%E6%8B%A9%E7%A5%9E%E5%85%BD-%E9%B8%BE%E9%B8%9F%E9%A2%84%E8%A7%88%E5%9B%BE.png',
|
|
|
+ 'https://wx-model-1317557471.cos.ap-shanghai.myqcloud.com/WXImage/%E9%80%89%E6%8B%A9%E7%A5%9E%E5%85%BD-%E5%BA%94%E9%BE%99%E9%A2%84%E8%A7%88%E5%9B%BE.png',
|
|
|
+ 'https://wx-model-1317557471.cos.ap-shanghai.myqcloud.com/WXImage/%E9%80%89%E6%8B%A9%E7%A5%9E%E5%85%BD-%E5%A4%AB%E8%AF%B8%E9%A2%84%E8%A7%88%E5%9B%BE.png',
|
|
|
+ 'https://wx-model-1317557471.cos.ap-shanghai.myqcloud.com/WXImage/%E9%80%89%E6%8B%A9%E7%A5%9E%E5%85%BD-%E7%8B%BB%E7%8C%8A%E9%A2%84%E8%A7%88%E5%9B%BE.png',
|
|
|
+ ],
|
|
|
+ log:"123",
|
|
|
+ },
|
|
|
+ onLoad(){
|
|
|
+
|
|
|
+ },
|
|
|
+ onShow(){
|
|
|
+ this.setData({log:'OnShow'});
|
|
|
+ var that = this;
|
|
|
+
|
|
|
+ wx.login({
|
|
|
+ success: (res) => {
|
|
|
+ if (res.code) {
|
|
|
+
|
|
|
+ console.log('用户登录成功,code:', res.code);
|
|
|
+
|
|
|
+ wx.request({
|
|
|
+ url: 'https://api-fat1.ghz-tech.com/miniprogram-shanhaijing/v1/product/listInfo',
|
|
|
+ method:'POST',
|
|
|
+ header:{
|
|
|
+ 'Content-Type':'application/json'
|
|
|
+ },
|
|
|
+ data:{
|
|
|
+ topic:1,
|
|
|
+ js_code:res.code
|
|
|
+ },
|
|
|
+ success:(res)=>{
|
|
|
+ console.log('POST 请求成功', res.data);
|
|
|
+ that.setData({log:'POST 请求成功'});
|
|
|
+ var products2 = res.data.data.products;
|
|
|
+ var modelImgs = this.data.modelImg;
|
|
|
+ console.log(' 商品列表 ',products2[0].desc);
|
|
|
+
|
|
|
+ for(var i =0;i<products2.length;i++){
|
|
|
+ products2[i]["modelImg"] = modelImgs[i];
|
|
|
+ if(products2[i].activate){
|
|
|
+ that.setData({uiShowIndex:i});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ that.setData({products:products2});
|
|
|
+ console.log(' 商品列表 ',this.data.products[0]);
|
|
|
+ that.setData({UiShowModel_Bottom:true});
|
|
|
+
|
|
|
+ },
|
|
|
+ fail:function(err){
|
|
|
+ console.error('POST 请求失败', err);
|
|
|
+ var errorlog = err.toString();
|
|
|
+ that.setData({log:errorlog});
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log('登录失败!' + res.errMsg);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ handleReady: function({detail}) {
|
|
|
+ this.setData({
|
|
|
+ sceneWidth: detail.width,
|
|
|
+ sceneHeight: detail.height,
|
|
|
+ recordWidth: detail.width,
|
|
|
+ recordHeight: detail.height,
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
handleProgress: function({detail}) {
|
|
|
console.log('assets progress', detail);
|
|
|
|
|
@@ -14,7 +115,222 @@ Page({
|
|
|
handlestr: function({detail}) {
|
|
|
|
|
|
|
|
|
- this.setData({loadedSaoMiao: true});
|
|
|
+ this.setData({
|
|
|
+ loadedSaoMiao: true,
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ clickZhaoHuan(e){
|
|
|
+ this.setData({zhaohuanstate:true});
|
|
|
+ this.setData({paizhaostate:false});
|
|
|
+ this.setData({luxiangstate:false});
|
|
|
+ this.setData({isStartluxiang:false});
|
|
|
+ },
|
|
|
+ clickPaiZhao(e){
|
|
|
+ this.setData({zhaohuanstate:false});
|
|
|
+ this.setData({paizhaostate:true});
|
|
|
+ this.setData({luxiangstate:false});
|
|
|
+ this.setData({isStartluxiang:false});
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ clickLuXiang(e){
|
|
|
+ this.setData({luxiangstate:true});
|
|
|
+ this.setData({zhaohuanstate:false});
|
|
|
+ this.setData({paizhaostate:false});
|
|
|
+ },
|
|
|
+ ClickzhaohuanSS(e){
|
|
|
+ this.setData({zhaohuanstate:false});
|
|
|
+ this.setData({uiMainView:false});
|
|
|
+ this.setData({uiShowModelView:true});
|
|
|
+ this.setData({uiShowNum:1});
|
|
|
+ },
|
|
|
+ Clickpaizhaoss(e){
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ fileType: 'png',
|
|
|
+ quality: 0.8
|
|
|
+ });
|
|
|
+
|
|
|
+ if(supported){
|
|
|
+
|
|
|
+
|
|
|
+ await this.scene.share.captureToFriends({
|
|
|
+ fileType: this.data.captureType,
|
|
|
+ quality: this.data.captureQuality
|
|
|
+ });
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (this.data.recordState) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '录屏中不允许!',
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.data.captureState) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '等待上次完成!',
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setData({captureState: 1});
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ this.setData({captureState: 0});
|
|
|
+ }, 1000);
|
|
|
+
|
|
|
+ },
|
|
|
+ Clickstartluxiang(e){
|
|
|
+
|
|
|
+ this.setData({isStartluxiang:true});
|
|
|
+ this.setData({recordState: 1});
|
|
|
+ },
|
|
|
+ Clickcloseluxiang(e){
|
|
|
+
|
|
|
+ this.setData({isStartluxiang:false});
|
|
|
+ this.setData({recordState: 0});
|
|
|
+ wx.showToast({
|
|
|
+ title: '视频录制完成',
|
|
|
+ });
|
|
|
+ },
|
|
|
+ changeCaptureState(e) {
|
|
|
+ if (this.data.recordState) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '录屏中不允许!',
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.data.captureState) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '等待上次完成!',
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setData({captureState: 1});
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ this.setData({captureState: 0});
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+ changeRecordState(e) {
|
|
|
+ this.setData({recordState: this.data.recordState ? 0 : 1});
|
|
|
+ },
|
|
|
+ clickCloseUIShow(e){
|
|
|
+ this.setData({uiMainView:true});
|
|
|
+ this.setData({zhaohuanstate:true});
|
|
|
+ this.setData({uiShowModelView:false});
|
|
|
+ },
|
|
|
+ clickJiSuoModel(e){
|
|
|
+
|
|
|
+ },
|
|
|
+ changeMoel:function(event){
|
|
|
+ var current2 = event.detail.current;
|
|
|
+ this.setData({
|
|
|
+ current:current2
|
|
|
+ })
|
|
|
+ },
|
|
|
+ clickShowLeft(e){
|
|
|
+
|
|
|
+ var leftoldIndex = this.data.uiShowNum;
|
|
|
+ if(leftoldIndex ==0){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ switch(this.data.uiShowIndex){
|
|
|
+ case 0:
|
|
|
+ this.setData({uiShowIndex:2});
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ this.setData({uiShowIndex:1});
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ this.setData({uiShowIndex:0});
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ let current = this.data.current;
|
|
|
+ current = current > 0 ? current - 1 : 0;
|
|
|
+ this.setData({
|
|
|
+ current: current,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ clickShowRight(e){
|
|
|
+ var oldIndex = this.data.uiShowIndex;
|
|
|
+ oldIndex = oldIndex+1;
|
|
|
+ var nIndex = oldIndex%3;
|
|
|
+ this.setData({uiShowIndex:nIndex});
|
|
|
+
|
|
|
+ let current = this.data.current;
|
|
|
+ current = current < 2 ? current + 1 : 2;
|
|
|
+ this.setData({
|
|
|
+ current: current,
|
|
|
+ });
|
|
|
+
|
|
|
+ },clickJiSuoModel(e){
|
|
|
+ var that = this;
|
|
|
+ wx.login({
|
|
|
+ success: (res) => {
|
|
|
+ if (res.code) {
|
|
|
+
|
|
|
+ console.log('用户登录成功,code:', res.code);
|
|
|
+ var modelId = this.data.products[this.data.current].id;
|
|
|
+ console.log('当前ModelId ', modelId);
|
|
|
+ wx.request({
|
|
|
+ url: 'https://api-fat1.ghz-tech.com/miniprogram-shanhaijing/v1/order/prepay',
|
|
|
+ method:'POST',
|
|
|
+ header:{
|
|
|
+ 'Content-Type':'application/json'
|
|
|
+ },
|
|
|
+ data:{
|
|
|
+ shop_cart:[{
|
|
|
+ id:modelId,
|
|
|
+ count:1
|
|
|
+ }],
|
|
|
+ js_code:res.code
|
|
|
+ },
|
|
|
+ success:function(res){
|
|
|
+ console.log('POST 请求成功', res.data.data);
|
|
|
+ var paySignStr = res.data.data.pay_Sign;
|
|
|
+ console.log('即将调取微信支付',res.data.data.pay_Sign);
|
|
|
+
|
|
|
+ wx.requestPayment({
|
|
|
+ nonceStr: res.data.data.nonce_str,
|
|
|
+ package: res.data.data.package,
|
|
|
+ paySign: res.data.data.pay_sign,
|
|
|
+ timeStamp: res.data.data.time_stamp,
|
|
|
+ signType:res.data.data.sign_type,
|
|
|
+ success(res){
|
|
|
+ console.log( '微信支付请求成功',res );
|
|
|
+
|
|
|
+
|
|
|
+ var products2 = that.data.products;
|
|
|
+ products2[that.data.current].activate = true;
|
|
|
+ that.setData({products:products2});
|
|
|
+ console.log('AAAA ',that.data.products);
|
|
|
+ var uiShowIndex2 = that.data.current;
|
|
|
+ that.setData({uiShowIndex:uiShowIndex2});
|
|
|
+ },
|
|
|
+ fail(err){
|
|
|
+ console.log('微信支付请求失败',err);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail:function(err){
|
|
|
+ console.error('POST 请求失败', err);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log('登录失败!' + res.errMsg);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
});
|
|
|
|