123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- import * as util from '../../../utils/util.js'
- Page({
-
- data: {
- dataPositionObj: {},
- propSize: {},
- isActive: '5',
- obverseImgObject: {},
- imgTouch: {},
- fontTouch: {},
- imgAnimationData: {},
- fontAnimationData: {},
- touchStatic: true,
- fontContent: '可定制区域',
- rpx: 1,
- imgSrcArray: [],
- imgBuildArray: [],
- simulation: {
- fontContent: '',
- fontSize: '',
- height: '',
- width: '',
- },
- dataId:['5','6']
- },
-
- onLoad: function (options) {
- let that = this;
- wx.getSystemInfo({
- success: function (res) {
- let rpx = res.windowWidth / 750;
- that.setData({
- rpx: rpx
- });
- console.log(rpx, 'rpx')
- },
- })
- if ('id' in options) {
- this.setData({
- isActive: options.id,
- dataId: options.dataId.split(',')
- })
- }
- },
-
- onReady: function () {
- let that = this;
-
- that.imgAnimation = wx.createAnimation({
- timingFunction: 'step-start',
- })
- that.fontAnimation = wx.createAnimation({
- timingFunction: 'step-start',
- })
- },
-
- onShow: function () {
- console.log('onshow')
- let that = this;
- let cupNum = util.changeCup(that.data.isActive);
- console.log(cupNum,"changeCup")
- that.setData({
- dataPositionObj: cupNum.dataPositionObj,
- propSize: cupNum.propSize,
- obverseImgObject: util.changeImg
- })
- that.getDataTouch(that)
- },
-
- onHide: function () {
- },
-
- onUnload: function () {
- },
-
- onPullDownRefresh: function () {
- },
-
- onReachBottom: function () {
- },
-
- onShareAppMessage: function () {
- },
-
-
-
-
-
-
-
-
- changeCup(e) {
- console.log(e,"点击了e")
- let that = this;
- let cupNum = util.changeCup(e.currentTarget.dataset.id);
- that.setData({
- isActive: e.currentTarget.dataset.id,
- dataPositionObj: cupNum.dataPositionObj,
- propSize: cupNum.propSize,
- })
- that.getDataTouch(that)
- },
- addImgRouter() {
- console.log('添加图片');
- wx.setStorageSync('box',this.data.box)
- wx.navigateTo({
- url: '/customized/pages/boxMade/boxMadeImg/boxMadeImg?id=' + this.data.isActive+'&dataId='+this.data.dataId,
- })
- },
- addFontRouter() {
- console.log('添加文字');
- wx.setStorageSync('box', this.data.box)
- wx.navigateTo({
- url: '/customized/pages/boxMade/boxMadeFont/boxMadeFont?id=' + this.data.isActive,
- })
- },
- getDataTouch(that) {
- let madeTouchImg = wx.getStorageSync('madeCupImgData' + that.data.isActive)
- let madeTouchFont = wx.getStorageSync('madeCupFontData' + that.data.isActive)
- console.log(madeTouchImg, madeTouchFont, "madeTouchFontmadeTouchFont")
- if (madeTouchImg || madeTouchFont) {
- that.setData({
- touchStatic: false
- })
- if (madeTouchImg) {
- that.imgAnimation.rotate(madeTouchImg.angle).step();
- that.setData({
- imgAnimationData: that.imgAnimation.export(),
- })
- }
- if (madeTouchFont) {
- that.fontAnimation.rotate(madeTouchFont.angle).step();
- that.setData({
- fontAnimationData: that.fontAnimation.export(),
- })
- that.setData({
- 'simulation.fontContent': madeTouchFont.fontContent,
- 'simulation.fontSize': madeTouchFont.fontSize
- })
- that.getTouchFontInformation(that)
- }
- } else {
- that.setData({
- touchStatic: true
- })
- }
- that.setData({
- imgTouch: madeTouchImg ? madeTouchImg : {},
- fontTouch: madeTouchFont ? madeTouchFont : {},
- })
- },
- finishDesign() {
- let that = this;
- let designObj = ['正面','背面'],
- designVal = '',
- madeStatic = false;
- for (let i = that.data.dataId[0] * 1; i <= that.data.dataId[1] * 1; i++) {
- if (!wx.getStorageSync('madeCupImgData' + i) && !wx.getStorageSync('madeCupFontData' + i)) {
- designVal += designObj[i - that.data.dataId[0] * 1] + ','
- } else {
- madeStatic = true;
- }
- }
- if (madeStatic) {
- if (!designVal) {
- console.log('可以完成')
- wx.navigateTo({
- url: '/customized/pages/boxMade/boxComb/boxComb?dataId=' + that.data.dataId
- })
- } else {
- wx.showModal({
- title: '温馨提示',
- content: '您的' + designVal.substring(0, designVal.length - 1) + '还没有设计,是否确定不设计了?',
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定,不设计了,直接完成')
- wx.navigateTo({
- url: '/customized/pages/boxMade/boxComb/boxComb?dataId=' + that.data.dataId
- })
- } else {
- console.log('用户点击取消')
- }
- }
- })
- }
- } else {
- wx.showToast({
- title: '您还没有设计',
- icon: 'none'
- })
- }
- },
- getTouchFontInformation(that) {
- let query = wx.createSelectorQuery();
- query.select('#simulation').boundingClientRect()
- query.exec(function (res) {
- console.log(res, "获取font的宽高");
- that.setData({
- 'simulation.height': res[0].height,
- 'simulation.width': res[0].width
- });
- wx.setStorageSync('simulationFont' + that.data.isActive, that.data.simulation);
- })
- },
- })
|