123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- var app = getApp();
- var coupon = [
- {
- coupon_monry : '1000',
- coupon_rule : '9999',
- coupon_name: '新年专属红包',
- coupon_begin_time: '2018-01-01',
- coupon_end_time: '2018-02-08'
- },
- {
- coupon_monry: '300',
- coupon_rule: '4999',
- coupon_name: '新年专属红包',
- coupon_begin_time: '2018-01-01',
- coupon_end_time: '2018-02-08'
- },
- {
- coupon_monry: '50',
- coupon_rule: '999',
- coupon_name: '新年专属红包',
- coupon_begin_time: '2018-01-01',
- coupon_end_time: '2018-02-08'
- }
- ];
- Page({
- data: {
- urlHttp: '',
- host : '',
- scrollLeft: 0,
- search:{
- placeholder:"输入搜索关键字"
- },
- navList:["推荐","中秋","改良生活","优化办公","智能科技"],
- firstActive: "header_nav_active",
- currentItem : '',
- flag:true,
- banners: [],
- rexiao: [],
- tuijian: [],
- tuijiannew: [],
- forviewFir: [],
- forviewSec: [],
- forviewtitele: '',
- title1: '',
- title2: '',
- title3: '',
- intro1: '',
- intro2: '',
- intro3: '',
- id1: '',
- id2: '',
- id3: '',
- src1: '',
- src2: '',
- src3: '',
- src4: '',
- src5: '',
- src6: '',
- price1: '',
- price2: '',
- price3: '',
- host: '',
- idTwo: '',
- find_name: '',
- find_id: '',
- find_logo: '',
- find_yuedu: '',
- find_shoucang: '',
- datatime: new Date().getTime(),
-
- city_name: '',
- jingpin: {
- id: 1, src: "../../images/jingxuan_banner.jpg", title: "各星座员工生日礼品如何选", liulan: 117, zan: 34
- },
- page: 1,
- hasMore: true,
- hidden : '',
- winHeight: "",
- coupon: coupon,
- showCoupon : false,
- couponSta : 0,
- un_id : '',
- showMsg : true,
- showChangeModel : false,
- bannerFlag : 0
- },
-
- tagChoose: function (options) {
- var that = this
- var name = options.currentTarget.dataset.name;
- var des = options.currentTarget.dataset.des;
- var forid = options.currentTarget.dataset.forid;
- wx:wx.navigateTo({
- url: '/pages/kindSecondList/kindSecondList?classify_name=' + name + '&classify_des=' + des + '&id=' + forid
- })
- },
-
- switchTab: function (e) {
- var that = this;
- var host = getApp().globalData.servsers;
- var current = e.detail.current;
- if (e.detail.current == 0){
- var forid = 0;
- }else{
- var forid = that.data.navList[e.detail.current - 1].id;
- var forname = that.data.navList[e.detail.current - 1].classify_name;
- var classifydes = that.data.navList[e.detail.current - 1].classify_des;
- }
-
- this.setData({
- currentItem: e.detail.current
- })
- if (forid > 0) {
- wx.request({
- url: that.data.host + "classifyapi/findAllforviewFir",
- data: {
- id: forid
- },
- method: 'GET',
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- wx.request({
- url: that.data.host + "commodityapi/findOneforxcx",
- data: {
- com_id: forid,
- },
- method: 'GET',
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- that.setData({
- tuijiannew: res.data.rows
- });
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
- that.setData({
- forviewFir: res.data.rows,
- forviewtitele: res.data.rows[0].classify_des,
- 'firstActive': "",
- flag: false,
- });
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
- } else {
-
- that.setData({
- 'firstActive': "",
- 'currentItem':0,
- flag: true,
- })
- }
- that.checkCor();
- },
- checkCor: function () {
- if (this.data.currentItem > 2) {
- this.setData({
- scrollLeft: 300
- })
- } else {
- this.setData({
- scrollLeft: 0
- })
- }
- },
- onLoad: function () {
- var that = this;
- var host = getApp().globalData.servsers;
- var un_id = getApp().globalData.un_id;
- that.setData({
- urlHttp : host
- })
-
- wx.request({
- url: host+"homebannerapi/homebannerall",
- data: {},
- method: 'GET',
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- that.setData({
- banners: res.data.rows,
- host: host
- });
- console.log(res.data.rows);
-
- for (var i = 0; i < res.data.rows.length;i++){
- var bannerFlag = that.data.bannerFlag;
- if (bannerFlag > 0){
- return false;
- }else{
- if (res.data.rows[i].banner_flag == 0) {
- bannerFlag++;
- that.setData({
- bannerFlag: bannerFlag
- })
- return false;
- }
- }
- }
-
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
-
-
- wx.request({
- url: host + "brandapi/findforfirst",
- data: {},
- method: 'GET',
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.rows[0] == undefined) {
- that.setData({
- hidden: 'hidden'
- })
- }else{
- var img = res.data.rows[0].brand_logo;
- that.setData({
- title1: res.data.rows[0].brand_name,
- intro1: res.data.rows[0].brand_des,
- src1: res.data.rows[0].brand_logo,
- src4: res.data.rows[0].brand_logo1,
- price1: res.data.rows[0].price,
- id1: res.data.rows[0].id,
- });
- }
- if (res.data.rows[1] == undefined) {
-
-
-
- } else {
- var img = res.data.rows[0].brand_logo;
- that.setData({
- title2: res.data.rows[1].brand_name,
- intro2: res.data.rows[1].brand_des,
- src2: res.data.rows[1].brand_logo,
- src5: res.data.rows[1].brand_logo1,
- price2: res.data.rows[1].price,
- id2: res.data.rows[1].id,
- });
- }
- if (res.data.rows[2] == undefined) {
-
-
-
- } else {
- var img = res.data.rows[0].brand_logo;
- that.setData({
- title3: res.data.rows[2].brand_name,
- intro3: res.data.rows[2].brand_des,
- src3: res.data.rows[2].brand_logo,
- src6: res.data.rows[2].brand_logo1,
- price3: res.data.rows[2].price,
- id3: res.data.rows[2].id,
- });
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- })
-
- wx.getSystemInfo({
- success: function (res) {
- var clientHeight = res.windowHeight,
- clientWidth = res.windowWidth,
- rpxR = 750 / clientWidth;
- var calc = clientHeight * rpxR;
- that.setData({
- winHeight: calc
- });
- }
- });
- },
- onReady:function(e){
- var that = this;
- var host = getApp().globalData.servsers;
-
- var beiginTime = '2017/12/28';
- var endTime = '2018/01/08';
- var beginTimestamp = beiginTime.replace(/-/g, '/');
- beginTimestamp = Date.parse(beginTimestamp);
- var endTimestamp = endTime.replace(/-/g, '/');
- endTimestamp = Date.parse(endTimestamp);
-
- var date = new Date();
- var Y = date.getFullYear();
- var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
- var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
- var nowTime = Y + '/' + M + '/' + D;
- nowTime = nowTime.replace(/-/g, '/');
- nowTime = Date.parse(nowTime);
- wx.login({
- success: function (res) {
- var code = res.code;
- wx.getUserInfo({
- withCredentials: true,
- success: function (res) {
- wx.request({
- url: host + "userapi/insertadd",
- data: {
- user_id: code,
- name: res.userInfo.nickName,
- icon: res.userInfo.avatarUrl,
- iv: res.iv,
- encryptedData: res.encryptedData,
- },
- method: 'GET',
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- that.setData({
- un_id: res.data.unionId
- })
- var un_id = res.data.unionId;
- if (parseInt(nowTime) >= parseInt(beginTimestamp) && parseInt(nowTime) <= parseInt(endTimestamp)) {
- console.log("un_id:" + un_id);
- if (un_id != undefined && un_id != '' && un_id != null){
- wx.request({
- url: host + "mycouponapi/getAlertFlag",
- data: {
- user_id: un_id,
- batch_no: 1,
- alert_num: 1
- },
- method: 'GET',
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data == 0) {
- that.setData({
- showCoupon: true
- })
- } else {
- that.setData({
- showCoupon: false
- })
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
- }
-
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- })
- }
- })
- }
- })
-
- },
- footerTap: app.footerTap,
- onShow:function(){
- var that = this;
- that.onLoad();
- },
-
- find:function(e){
- wx.switchTab({
- url : "/pages/find/index"
- })
- },
-
- onPullDownRefresh: function (e) {
- var that = this;
- that.onLoad();
- wx.stopPullDownRefresh();
- },
- onShareAppMessage: function (res) {
- var that = this;
- var host = getApp().globalData.servsers;
- if (res.from === 'button') {
-
- console.log(res.target)
- }
- return {
- title:'大良造-精良之选,用心造物!',
- path: '/pages/index/index',
- success: function (res) {
-
- },
- fail: function (res) {
-
- }
- }
- },
-
- closeCoupon:function(e){
- var that = this;
- that.setData({
- showCoupon : false
- })
- },
-
- closeMsg:function(e){
- var that = this;
- that.setData({
- showMsg : false
- })
- },
-
- openChangeModel:function(e){
- var that = this;
- that.setData({
- showMsg: false,
- showChangeModel: true
- })
- },
-
- goChooseGift:function(e){
- var that = this;
- that.setData({
- showChangeModel : false
- })
- wx.navigateTo({
- url: '/pages/patternMenu/patternMenu'
- })
- },
-
- closeChangeModel:function(e){
- var that = this;
- that.setData({
- showChangeModel: false
- })
- }
- })
- var banners = []
- var rexiao = []
- var pinpai = []
- var tuijian = []
- var that;
- var Util = require('../../utils/util.js');
|