123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- var app = getApp()
- var that;
- Page({
- data: {
- detail: {},
- id: '',
- is: true,//是否是发放员进来
- disabled: false,
- sn:'',
- image:'',
- isShowYy:false,
- corpId:'',
- },
- onLoad(e) {
- that = this;
- dd.setNavigationBar({ title: "奖品兑换详情" });
- if (e.id) {
- this.setData({ id: e.id })
- }
- if (e.is) {
- this.setData({ is: false })
- }
- if (e.corpId) {
- this.setData({ corpId: e.corpId })
- }
- console.log(e)
- },
- onShow(e) {
- if (app.globalData.userData) {
- app.globalData.userData.employee_detail.role_list.forEach(item=>{
- if(item.name=='admin'||item.name=='creator'|| item.name == 'point_manager'){
- this.setData({ isShowYy: true })
- }
- })
- that.getData();
- } else {
- app.login(that.data.corpId||app.globalData.corpId, function (is) {
- if (is) {
- app.globalData.userData.employee_detail.role_list.forEach(item=>{
- if(item.name=='admin'||item.name=='creator'|| item.name == 'point_manager'){
- this.setData({ isShowYy: true })
- }
- })
- that.getData();
- } else {
- dd.reLaunch({
- url: '../../noJurisdiction/noJurisdiction'
- })
- }
- }, function () { })
- }
- },
- showImg(e) {
- var url = e.target.dataset.url
- dd.previewImage({
- current: 0,
- urls:[url]
- });
- },
- openText() {
- this.setData({ disabled: true });
- app.$post("api/shop/exchange/deal", { id: this.data.id }).then((res) => {
- app.globalData.showToast("已发放");
- setTimeout(() => {
- this.setData({ disabled: false });
- this.getData()
- }, 1000);
- }).catch(err => {
- this.setData({ disabled: false });
- })
- },
- showText() {
- app.$get('api/shop/exchange/qrcode', { id: this.data.id, employee_id: app.globalData.userData.id }).then((res) => {
- this.setData({
- image: app.globalData.baseUrl + res.data.data,
- })
- })
- this.setData({
- isBh: !this.data.isBh,
- })
- },
- showText2() {
- this.setData({
- isBh: !this.data.isBh,
- })
- },
- handleCopy() {
- dd.setClipboard({
- text: this.data.detail.sn,
- })
- app.globalData.showToast("已复制");
- },
- getData() {
- app.$get('api/shop/exchange/detail', { id: this.data.id }).then((res) => {
- let data = res.data.data;
- data.date = this.timestampToTime(data.create_time)
- data.date2 = this.timestampToTime(data.complete_time)
- this.setData({ detail: res.data.data })
- })
- },
- timestampToTime(timestamp) {
- var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
- var Y = date.getFullYear() + '-';
- var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
- var D = date.getDate() + ' ';
- var h = date.getHours() + ':';
- var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() ) + ':';
- var s = date.getSeconds();
- return Y + M + D + h + m + s;
- },
- });
|