123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
- // pages/kabaw/detail.js
- // 引入SDK核心类
- var QQMapWX = require('../../utils/qqmap-wx-jssdk.min.js');
- // 实例化API核心类
- var qqmapsdk = new QQMapWX({
- key: 'YGZBZ-QSKCU-7LGVI-2WWXU-E5YEJ-2WFBA' // 必填
- });
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- is_sell: 1,
- qrurl: '',
- detail: '',
- way: '',
- useqr: false
- },
- //在Page({})中使用下列代码
- //触发表单提交事件,调用接口
- jingwei(e) {
- var _this = this;
- //调用地址解析接口
- qqmapsdk.geocoder({
- //获取表单传入地址
- address: e, //地址参数,例:固定地址,address: '北京市海淀区彩和坊路海淀西大街74号'
- success: function (res) {//成功后的回调
- console.log(res);
- var res = res.result;
- var latitude = res.location.lat;
- var longitude = res.location.lng;
- wx.getLocation({
- type: 'gcj02', //返回可以用于wx.openLocation的经纬度
- success(res) {
- const latitude = latitude
- const longitude = longitude
- wx.openLocation({
- latitude,
- longitude,
- scale: 18
- })
- }
- })
- },
- fail: function (error) {
- console.error(error);
- },
- complete: function (res) {
- console.log(res);
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.jingwei('成都市傲城')
- console.log(options)
- this.setData({
- way: options.way
- })
- var id = options.id
- if (options.way == 'use') {
- this.getdetail(id)
- } else {
- this.getbuydetail(id)
- }
- },
- getdetail: function (id) {
- var that = this
- console.log(getApp().api.everyday_coupon.user_info)
- getApp().request({
- url: getApp().api.everyday_coupon.carddetail,
- data: {
- user_card_id: id
- },
- success: function (t) {
- console.log(t)
- var list = t.data.card
- that.setData({
- detail: list
- })
- }
- })
- },
- getbuydetail: function (id) {
- var that = this
- console.log(getApp().api.everyday_coupon.user_info)
- getApp().request({
- url: getApp().api.everyday_coupon.cardbuydetail,
- data: {
- id:id
- },
- success: function (t) {
- console.log(t)
- var list = t.data.list
- that.setData({
- detail: list
- })
- }
- })
- },
- touse: function () {
- var that = this
- console.log('使用优惠券')
- },
- useit: function () {
- var that = this
- console.log('购买优惠券')
- var that = this
- console.log(getApp().api.everyday_coupon.user_info)
- getApp().request({
- url: getApp().api.everyday_coupon.usevipcard,
- data: {
- user_vip_id: that.data.detail.id,
- },
- success: function (t) {
- console.log(t)
- if(t.code!=0){
- return wx.showModal({
- title: '提示',
- content: t.msg,
- showCancel:false
- })
- }
- var url = ''
- if (t.data) {
- url = t.data.url ? t.data.url : '';
- } else {
- }
- that.setData({
- useqr: true,
- qrurl: url
- })
- }
- })
- },
- shuaxin: function () {
- var that = this
- wx.showModal({
- title: '提示',
- content: '确定刷新吗?',
- success: function (res) {
- if (res.confirm) {
- console.log('1')
- } else {
- console.log('0')
- }
- }
- })
- },
- gothere: function () {
- var that = this
- wx.getLocation({//获取当前经纬度
- type: 'wgs84', //返回可以用于wx.openLocation的经纬度,官方提示bug: iOS 6.3.30 type 参数不生效,只会返回 wgs84 类型的坐标信息
- success: function (res) {
- wx.openLocation({//使用微信内置地图查看位置。
- latitude: that.data.detail.lat,
- longitude: that.data.detail.lon,
- name: that.data.detail.shop_name,
- address: that.data.detail.address,
- })
- }
- })
- },
- close: function () {
- this.setData({
- useqr: false
- })
- },
- nopay: function (id) {
- var that = this
- var that = this
- console.log(getApp().api.everyday_coupon.user_info)
- getApp().request({
- url: getApp().api.everyday_coupon.cancelpaycard,
- data: {
- order_no: id,
- // send_id: that.data.send_id
- },
- success: function (t) {
- console.log(t)
- if (t.code != 0) {
- return wx.showModal({
- title: '提示',
- content: t.msg,
- showCancel: false
- })
- }
- }
- })
- },
- buy: function () {
- var that = this
- console.log('购买vip')
- var that = this
- console.log(getApp().api.everyday_coupon.user_info)
- getApp().request({
- url: getApp().api.everyday_coupon.getvipcard,
- data: {
- id: that.data.detail.id,
- send_id: that.data.send_id
- },
- success: function (t) {
- console.log(t)
- if (t.code != 0) {
- return wx.showModal({
- title: '提示',
- content: t.msg,
- showCancel: false,
- success: function (res) {
- that.nopay(t.order_no)
- }
- })
- }
- var dt = t.data
- if (that.data.detail.is_pay == 1) {
- wx.requestPayment(
- {
- 'timeStamp': dt.timeStamp,
- 'nonceStr': dt.nonceStr,
- 'package': dt.package,
- 'signType': 'MD5',
- 'paySign': dt.paySign,
- 'success': function (res) {
- console.log(res)
- // wx.redirectTo({
- // url: '/pages/kabaw/viplist',
- // })
- wx.navigateBack({
- })
- },
- 'fail': function (res) {
- console.log('失败',res)
- that.nopay(t.order_no)
- },
- 'complete': function (res) {
- }
- })
- } else {
- wx.showModal({
- title: '提示',
- content: '领取成功',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- // wx.redirectTo({
- // url: '/pages/kabaw/kabaw',
- // })
- wx.navigateBack({
- })
- }
- }
- })
- }
- }
- })
- },
- delthis:function(e){
- var that = this
- var id = e.currentTarget.dataset.id
- console.log('购买优惠券')
- wx.showModal({
- title: '提示',
- content: '确认删除吗?',
- success:function(res){
- if(res.confirm){
- console.log(getApp().api.everyday_coupon.user_info)
- getApp().request({
- url: getApp().api.everyday_coupon.delcard,
- data: {
- id: id,
- // send_id: that.data.send_id
- },
- success: function (t) {
- console.log(t)
- if (t.code != 0) {
- return wx.showModal({
- title: '提示',
- content: t.msg,
- showCancel: false
- })
- } else {
- return wx.showModal({
- title: '提示',
- content: '删除成功',
- showCancel: false,
- success:function(res){
- if (res.confirm) {
- wx.navigateBack({
- delta: 2
- })
- }
- }
- })
- }
- }
- })
- }else{
- }
- }
- })
-
- },
- del: function (id) {
- var that = this
- console.log('购买优惠券')
- var that = this
- console.log(getApp().api.everyday_coupon.user_info)
- getApp().request({
- url: getApp().api.everyday_coupon.delcard,
- data: {
- id: that.data.detail.id,
- // send_id: that.data.send_id
- },
- success: function (t) {
- console.log(t)
- if (t.code != 0) {
- return wx.showModal({
- title: '提示',
- content: t.msg,
- showCancel: false
- })
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|