carddetail.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. // pages/kabaw/detail.js
  2. // 引入SDK核心类
  3. var QQMapWX = require('../../utils/qqmap-wx-jssdk.min.js');
  4. // 实例化API核心类
  5. var qqmapsdk = new QQMapWX({
  6. key: 'YGZBZ-QSKCU-7LGVI-2WWXU-E5YEJ-2WFBA' // 必填
  7. });
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. is_sell: 1,
  14. qrurl: '',
  15. detail: '',
  16. way: '',
  17. useqr: false
  18. },
  19. //在Page({})中使用下列代码
  20. //触发表单提交事件,调用接口
  21. jingwei(e) {
  22. var _this = this;
  23. //调用地址解析接口
  24. qqmapsdk.geocoder({
  25. //获取表单传入地址
  26. address: e, //地址参数,例:固定地址,address: '北京市海淀区彩和坊路海淀西大街74号'
  27. success: function (res) {//成功后的回调
  28. console.log(res);
  29. var res = res.result;
  30. var latitude = res.location.lat;
  31. var longitude = res.location.lng;
  32. wx.getLocation({
  33. type: 'gcj02', //返回可以用于wx.openLocation的经纬度
  34. success(res) {
  35. const latitude = latitude
  36. const longitude = longitude
  37. wx.openLocation({
  38. latitude,
  39. longitude,
  40. scale: 18
  41. })
  42. }
  43. })
  44. },
  45. fail: function (error) {
  46. console.error(error);
  47. },
  48. complete: function (res) {
  49. console.log(res);
  50. }
  51. })
  52. },
  53. /**
  54. * 生命周期函数--监听页面加载
  55. */
  56. onLoad: function (options) {
  57. this.jingwei('成都市傲城')
  58. console.log(options)
  59. this.setData({
  60. way: options.way
  61. })
  62. var id = options.id
  63. if (options.way == 'use') {
  64. this.getdetail(id)
  65. } else {
  66. this.getbuydetail(id)
  67. }
  68. },
  69. getdetail: function (id) {
  70. var that = this
  71. console.log(getApp().api.everyday_coupon.user_info)
  72. getApp().request({
  73. url: getApp().api.everyday_coupon.carddetail,
  74. data: {
  75. user_card_id: id
  76. },
  77. success: function (t) {
  78. console.log(t)
  79. var list = t.data.card
  80. that.setData({
  81. detail: list
  82. })
  83. }
  84. })
  85. },
  86. getbuydetail: function (id) {
  87. var that = this
  88. console.log(getApp().api.everyday_coupon.user_info)
  89. getApp().request({
  90. url: getApp().api.everyday_coupon.cardbuydetail,
  91. data: {
  92. id:id
  93. },
  94. success: function (t) {
  95. console.log(t)
  96. var list = t.data.list
  97. that.setData({
  98. detail: list
  99. })
  100. }
  101. })
  102. },
  103. touse: function () {
  104. var that = this
  105. console.log('使用优惠券')
  106. },
  107. useit: function () {
  108. var that = this
  109. console.log('购买优惠券')
  110. var that = this
  111. console.log(getApp().api.everyday_coupon.user_info)
  112. getApp().request({
  113. url: getApp().api.everyday_coupon.usevipcard,
  114. data: {
  115. user_vip_id: that.data.detail.id,
  116. },
  117. success: function (t) {
  118. console.log(t)
  119. if(t.code!=0){
  120. return wx.showModal({
  121. title: '提示',
  122. content: t.msg,
  123. showCancel:false
  124. })
  125. }
  126. var url = ''
  127. if (t.data) {
  128. url = t.data.url ? t.data.url : '';
  129. } else {
  130. }
  131. that.setData({
  132. useqr: true,
  133. qrurl: url
  134. })
  135. }
  136. })
  137. },
  138. shuaxin: function () {
  139. var that = this
  140. wx.showModal({
  141. title: '提示',
  142. content: '确定刷新吗?',
  143. success: function (res) {
  144. if (res.confirm) {
  145. console.log('1')
  146. } else {
  147. console.log('0')
  148. }
  149. }
  150. })
  151. },
  152. gothere: function () {
  153. var that = this
  154. wx.getLocation({//获取当前经纬度
  155. type: 'wgs84', //返回可以用于wx.openLocation的经纬度,官方提示bug: iOS 6.3.30 type 参数不生效,只会返回 wgs84 类型的坐标信息
  156. success: function (res) {
  157. wx.openLocation({//​使用微信内置地图查看位置。
  158. latitude: that.data.detail.lat,
  159. longitude: that.data.detail.lon,
  160. name: that.data.detail.shop_name,
  161. address: that.data.detail.address,
  162. })
  163. }
  164. })
  165. },
  166. close: function () {
  167. this.setData({
  168. useqr: false
  169. })
  170. },
  171. nopay: function (id) {
  172. var that = this
  173. var that = this
  174. console.log(getApp().api.everyday_coupon.user_info)
  175. getApp().request({
  176. url: getApp().api.everyday_coupon.cancelpaycard,
  177. data: {
  178. order_no: id,
  179. // send_id: that.data.send_id
  180. },
  181. success: function (t) {
  182. console.log(t)
  183. if (t.code != 0) {
  184. return wx.showModal({
  185. title: '提示',
  186. content: t.msg,
  187. showCancel: false
  188. })
  189. }
  190. }
  191. })
  192. },
  193. buy: function () {
  194. var that = this
  195. console.log('购买vip')
  196. var that = this
  197. console.log(getApp().api.everyday_coupon.user_info)
  198. getApp().request({
  199. url: getApp().api.everyday_coupon.getvipcard,
  200. data: {
  201. id: that.data.detail.id,
  202. send_id: that.data.send_id
  203. },
  204. success: function (t) {
  205. console.log(t)
  206. if (t.code != 0) {
  207. return wx.showModal({
  208. title: '提示',
  209. content: t.msg,
  210. showCancel: false,
  211. success: function (res) {
  212. that.nopay(t.order_no)
  213. }
  214. })
  215. }
  216. var dt = t.data
  217. if (that.data.detail.is_pay == 1) {
  218. wx.requestPayment(
  219. {
  220. 'timeStamp': dt.timeStamp,
  221. 'nonceStr': dt.nonceStr,
  222. 'package': dt.package,
  223. 'signType': 'MD5',
  224. 'paySign': dt.paySign,
  225. 'success': function (res) {
  226. console.log(res)
  227. // wx.redirectTo({
  228. // url: '/pages/kabaw/viplist',
  229. // })
  230. wx.navigateBack({
  231. })
  232. },
  233. 'fail': function (res) {
  234. console.log('失败',res)
  235. that.nopay(t.order_no)
  236. },
  237. 'complete': function (res) {
  238. }
  239. })
  240. } else {
  241. wx.showModal({
  242. title: '提示',
  243. content: '领取成功',
  244. showCancel: false,
  245. success: function (res) {
  246. if (res.confirm) {
  247. // wx.redirectTo({
  248. // url: '/pages/kabaw/kabaw',
  249. // })
  250. wx.navigateBack({
  251. })
  252. }
  253. }
  254. })
  255. }
  256. }
  257. })
  258. },
  259. delthis:function(e){
  260. var that = this
  261. var id = e.currentTarget.dataset.id
  262. console.log('购买优惠券')
  263. wx.showModal({
  264. title: '提示',
  265. content: '确认删除吗?',
  266. success:function(res){
  267. if(res.confirm){
  268. console.log(getApp().api.everyday_coupon.user_info)
  269. getApp().request({
  270. url: getApp().api.everyday_coupon.delcard,
  271. data: {
  272. id: id,
  273. // send_id: that.data.send_id
  274. },
  275. success: function (t) {
  276. console.log(t)
  277. if (t.code != 0) {
  278. return wx.showModal({
  279. title: '提示',
  280. content: t.msg,
  281. showCancel: false
  282. })
  283. } else {
  284. return wx.showModal({
  285. title: '提示',
  286. content: '删除成功',
  287. showCancel: false,
  288. success:function(res){
  289. if (res.confirm) {
  290. wx.navigateBack({
  291. delta: 2
  292. })
  293. }
  294. }
  295. })
  296. }
  297. }
  298. })
  299. }else{
  300. }
  301. }
  302. })
  303. },
  304. del: function (id) {
  305. var that = this
  306. console.log('购买优惠券')
  307. var that = this
  308. console.log(getApp().api.everyday_coupon.user_info)
  309. getApp().request({
  310. url: getApp().api.everyday_coupon.delcard,
  311. data: {
  312. id: that.data.detail.id,
  313. // send_id: that.data.send_id
  314. },
  315. success: function (t) {
  316. console.log(t)
  317. if (t.code != 0) {
  318. return wx.showModal({
  319. title: '提示',
  320. content: t.msg,
  321. showCancel: false
  322. })
  323. }
  324. }
  325. })
  326. },
  327. /**
  328. * 生命周期函数--监听页面初次渲染完成
  329. */
  330. onReady: function () {
  331. },
  332. /**
  333. * 生命周期函数--监听页面显示
  334. */
  335. onShow: function () {
  336. },
  337. /**
  338. * 生命周期函数--监听页面隐藏
  339. */
  340. onHide: function () {
  341. },
  342. /**
  343. * 生命周期函数--监听页面卸载
  344. */
  345. onUnload: function () {
  346. },
  347. /**
  348. * 页面相关事件处理函数--监听用户下拉动作
  349. */
  350. onPullDownRefresh: function () {
  351. },
  352. /**
  353. * 页面上拉触底事件的处理函数
  354. */
  355. onReachBottom: function () {
  356. },
  357. /**
  358. * 用户点击右上角分享
  359. */
  360. onShareAppMessage: function () {
  361. }
  362. })