123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- var businessT = require('../../../tool/business-tool.js')
- var sysT = require('../../../tool/sys-tool.js')
- var url = require('../../../constant/url.js')
- import Net from '../../../tool/net.js'
- var net = new Net()
- var app = getApp()
- Page({
- data: {
- type: '',
- surveyData: [
- { q: ' 缴纳社保,请问您是为了?', t: '(可多选)', a: ['买房', '买车', '退休养老金', '入户', '子女入学', '贷款', '其他'], btn: ' 下一题' },
- { q: ' 缴存公积金,请问您是为了?', t: '(可多选)', a: ['买房', '贷款', '存钱储蓄', '其他'], btn: ' 下一题' },
- { q: ' 您是如何知道“我的社保”小程序?', a: ['朋友介绍', '百度关键词搜索', '支付宝生活号/小程序', '微信公众号', '其他'], btn: ' 提交' },
- ],
- scorllLeft: 0,
- status: false,
- current: 0,
- seleted: [],
- answerData: [],
- modalStatus: false,
- },
- next(e) {
- var id = Number(e.currentTarget.id), screenWidth = sysT.sysInfo().screenWidth, current = this.data.current, str = ''
- if (!this.data.status) { return }
- this.data.topic[current].a.forEach((item, index) => {
- if (this.data.seleted[index]) {
- str += item + '#'
- }
- })
- str = str.slice(0, -1)
- this.data.answerData[current] = str
- console.log(this.data.answerData)
- this.data.scorllLeft += screenWidth
- current += 1
- if (id + 1 == this.data.topic.length) {
- var answer1, answer2, answer3
- if (this.data.surveyType == 1) {
- answer1 = this.data.answerData[0]
- answer2 = ''
- answer3 = this.data.answerData[1]
- } else if (this.data.surveyType == 2) {
- answer1 = ''
- answer2 = this.data.answerData[0]
- answer3 = this.data.answerData[1]
- } else {
- answer1 = this.data.answerData[0]
- answer2 = this.data.answerData[1]
- answer3 = this.data.answerData[2]
- }
- swan.showLoading({
- title: '请稍后...',
- mask: true
- });
- net.connectNeedLogin({
- url: url.app_host + url.saveSurvey,
- data: { answer1, answer2, answer3 },
- success: (err, res) => {
- swan.hideLoading()
- this.setData({ scorllLeft: this.data.scorllLeft, current, status: false, seleted: [], discount: res.data })
- this.countTime()
- },
- fail: (err, res) => {
- swan.hideLoading()
- businessT.showFailTips(err)
- this.hiddenModal()
- }
- })
- } else {
- this.setData({ scorllLeft: this.data.scorllLeft, current, status: false, seleted: [] })
- }
- },
- choose(e) {
- var index = e.currentTarget.dataset.index, current = this.data.current, status
- this.data.seleted[index] = !this.data.seleted[index]
- if (this.data.seleted[index]) {
- status = true
- } else {
- status = false
- this.data.seleted.forEach(item => {
- if (item) {
- status = true
- }
- })
- }
- this.setData({ seleted: this.data.seleted, status })
- },
- showModal() {
- const animation = swan.createAnimation()
- animation.translateY(-600).step();
- this.setData({ modalStatus: true }, () => {
- this.setData({
- animationData: animation.export()
- })
- })
- },
- hiddenModal() {
- const animation = swan.createAnimation()
- animation.translateY(0).step();
- this.setData({ animationData: animation.export() }, () => {
- setTimeout(() => {
- this.setData({
- modalStatus: false,
- scorllLeft: 0,
- answerData: [],
- seleted: [],
- current: 0
- })
- }, 400)
- })
- },
- countTime() {
- var now = new Date().format('yyyy-MM-dd h:m:s'), discount = this.data.discount
- var nowDate = now.slice(0, 10)
- var endDate = discount.end_time.slice(0, 10)
- if (nowDate == endDate) {
- discount.p = '今天过期'
- } else {
- var tempNowDate = nowDate + ' 00:00:00'
- var tempEndDate = endDate + ' 00:00:00'
- var d = businessT.dateDiff('d', tempNowDate, tempEndDate)
- if (tempEndDate == discount.end_time) {
- d -= 1
- }
- if (d == 0) {
- discount.p = '今天过期'
- } else {
- discount.p = '还有' + d + '天过期'
- }
- }
- this.setData({ discount })
- },
- shareAction() {
- swan.openShare({
- path: '/page/home/index/index',
- imageUrl: '../../../icon/public/share_img.png',
- title: '自助缴社保公积金,覆盖200多个城市,专业团队操作',
- success:()=>{
- swan.switchTab({
- url: '../../../page/mypage/index/index',
- });
- }
- });
- },
- repair(){
- swan.navigateTo({
- url: '../../../page/mypage/pages/repair/repair',
- });
- },
- goMypage(){
- swan.switchTab({
- url: '../../../page/mypage/index/index',
- });
- },
- salary(){
- swan.navigateTo({
- url: '../../../page/mypage/pages/turnover/turnover',
- });
- },
- addCard(){
- var arr=app.globalData.customerList.filter(item=>{
- return item.id==this.data.id
- })
- swan.navigateTo({
- url: '../edit-bank/edit-bank?current='+JSON.stringify(arr[0]),
- });
- },
- onLoad: function (res) {
- // 监听页面加载的生命周期函数
- var topic, surveyData = this.data.surveyData, surveyType
- if (res.payfor == 1) {
- surveyType = 1
- topic = [surveyData[0], surveyData[2]]
- } else if (res.payfor == 2) {
- surveyType = 2
- topic = [surveyData[1], surveyData[2]]
- } else {
- surveyType = 3
- topic = [surveyData[0], surveyData[1], surveyData[2]]
- }
- this.setData({ suffix: sysT.suffixOfClass(), surveyType, topic, type: res.type,id:res.id })
- },
- onReady: function () {
- // 监听页面初次渲染完成的生命周期函数
- },
- onShow: function () {
- // 监听页面显示的生命周期函数
- },
- onHide: function () {
- // 监听页面隐藏的生命周期函数
- },
- onUnload: function () {
- // 监听页面卸载的生命周期函数
- },
- onPullDownRefresh: function () {
- // 监听用户下拉动作
- },
- onReachBottom: function () {
- // 页面上拉触底事件的处理函数
- },
- onShareAppMessage: function () {
- // 用户点击右上角转发
- }
- });
|