123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- // pages/home/search/search.js
- const app = getApp()
- const url = require('../../../utils/url.js')
- var call = require("../../../utils/net.js")
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- issearch:null,//搜索默认页搜索结果页
- condition:false,
- search: {
- pla: "搜索 社保/公积金/身份证"
- },
- recommend:[
- { name: '社保五险', img:'/icon/search/shebaowuxian.png'},
- { name: '养老保险', img: '/icon/search/yanglaobaoxian.png'},
- { name: '医疗保险', img: '/icon/search/yiliaobaoxian.png' },
- { name: '生育保险', img: '/icon/search/shengyubaoxian.png' },
- { name: '工商保险', img: '/icon/search/gongshangbaoxian.png' },
- { name: '事业保险', img: '/icon/search/shiyebaoxian.png' },
- ],
- hotSearch: ['社保查询', '养老保险', '养老', '五险一金', '驾驶证', '港澳通行证'],
- question: {
- range: null
- }
- },
- //查看详情要进行授权
- getUserInfo(e) {
- //console.log(e)
- let ids = e.currentTarget.dataset.ids;
- let title = e.currentTarget.dataset.title;
- var userId = wx.getStorageSync('userId');
- if (userId) {
- wx.navigateTo({
- url: '/pages/home/detail/detail?id=' + ids + '&title=' + title,
- })
- } else {
- if (e.detail.errMsg == 'getUserInfo:ok') {
- let reqData = {
- 'signature': e.detail.signature,
- 'rawData': e.detail.rawData
- }
- wx.login({
- success(res) {
- if (res.code) {
- let code = res.code
- reqData['code'] = code
- call.request(url.host + url.login,
- { code: res.code },
- res => {
- //console.log(res.data)
- wx.setStorageSync('userId', res.data.data); //将userId存入本地缓存
- if (res.data.code == 200) {
- call.request(url.host + url.getuserinfo,
- reqData,
- res => {
- wx.navigateTo({
- url: '/pages/home/detail/detail?id=' + ids + '&title=' + title,
- })
- console.log(res)
- },
- res => {
- console.log(res)
- })
- } else {
- wx.showToast({
- icon: 'none',
- title: res.data.msg,
- })
- }
- },
- res => {
- console.log(res)
- })
- } else {
- console.log('登录失败!' + res.errMsg)
- }
- }
- })
- } else if (e.detail.errMsg == 'getUserInfo:fail auth deny') {
- wx.showToast({
- icon: 'none',
- title: '授权失败!',
- })
- }
- }
- },
- //取消返回上一页
- backpage:function(){
- wx.navigateBack({
- delta: 1
- })
- },
- //跳转详情
- // toproblem: function (e) {
- // let ids = e.currentTarget.dataset.ids;
- // wx.navigateTo({
- // url: '/pages/home/detail/detail?id=' + ids,
- // })
- // },
- //搜索
- confirm: function (e) {
- var that = this
- let word = e.detail.value;
- //查询接口
- if (word.match(/^\s*$/) || word == null || word == undefined || word == ''){
- wx.showToast({
- title: '请输入搜索关键词!',
- icon: 'none',
- duration: 2000
- })
- }else{
- wx.showLoading({
- mask: true,
- title: '搜索中...',
- });
- call.request(url.host + url.query,
- { city: app.globalData.city, word: word },
- res => {
- console.log(res)
- if(res.data.code == 200){
- that.setData({
- titltRange: res.data.data
- })
- }else{
- wx.showToast({
- icon: 'none',
- title: res.data.msg,
- })
- }
- wx.hideLoading()
- },
- res => {
- console.log(res)
- wx.hideLoading()
- })
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this;
- call.request(url.host + url.query,
- { city: app.globalData.city , word: options.word },
- res => {
- console.log(res)
- let word = "search.word"
- that.setData({
- [word]: options.word,
- titltRange: res.data.data
- })
- },
- res => {
- console.log(res)
- })
-
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|