Blame view

pages/businessCard/printCard.vue 5.58 KB
36884ffd   刘淇   打印
1
2
  <template>
      <view>
9bac797d   刘淇   卡券发放
3
          <uni-section :title="`${cardRuleName}(${cardTypeName})`" type="line">
36884ffd   刘淇   打印
4
5
              <uni-card padding="0" spacing="0">
                  <uni-list>
9bac797d   刘淇   卡券发放
6
                      <uni-list-item title="适应车场" :rightText="plName">
36884ffd   刘淇   打印
7
8
                          <text></text>
                      </uni-list-item>
265d418c   刘淇   商户券 价格
9
                      <uni-list-item :title="`价格:¥${(price/100).toFixed(2)}/张`" :rightText="`商户库存:${cardNum}张`"></uni-list-item>
36884ffd   刘淇   打印
10
11
12
13
                  </uni-list>
              </uni-card>
          </uni-section>
  
9bac797d   刘淇   卡券发放
14
          <view class=" uni-card text-center" style="padding: 10px 0">
1fa597c2   刘淇   二维码大小
15
              <image :src="qrUrl" style="width: 300px;height:300px;margin: 0 auto;" @longpress="savePosterPath(qrUrl)"></image>
36884ffd   刘淇   打印
16
17
          </view>
  
c9d45ef5   刘淇   商户券 有效期
18
          <view style="padding: 5px 10px">长按上面二维码可以保存为图片</view>
9bac797d   刘淇   卡券发放
19
20
  
          <view class=" uni-card" style="padding: 10px 15px">
c9d45ef5   刘淇   商户券 有效期
21
22
23
              <view style="padding-bottom: 10px;">选择二维码有效期</view>
              <!--<uni-number-box @change="changeValue" min="1"/>-->
              <uni-datetime-picker v-model="single" :start="startTime" />
fc8d2d1a   刘淇   打印
24
25
          </view>
  
36884ffd   刘淇   打印
26
          <view class="uni-padding-wrap uni-common-mt">
fc8d2d1a   刘淇   打印
27
              <!--<button type="primary" style="margin-bottom: 15px">停止自动发放</button>-->
de23b5ec   刘淇   生成二维码
28
              <button type="warn" @click="changeTime">重新生成二维码</button>
36884ffd   刘淇   打印
29
30
31
32
33
34
35
          </view>
  
  
      </view>
  </template>
  
  <script>
9bac797d   刘淇   卡券发放
36
  import uQRCode from '../../common/uqrcode.js' //引入uqrcode.js
36884ffd   刘淇   打印
37
38
  export default {
    data() {
36884ffd   刘淇   打印
39
      return {
9bac797d   刘淇   卡券发放
40
41
42
43
44
45
46
        cardTypeName: '',// 卡类型名称
        cardRuleName: '',// 卡名称
        plName: '', // 停车场
        price: '', // 卡价格
        cardNum: '', // 库存
        cardRelParkNo: '',//商券规则关联车场和商户编码
        numberValue: '1',
c9d45ef5   刘淇   商户券 有效期
47
        deadline: '2099-10-01 00:00:00',
9bac797d   刘淇   卡券发放
48
        qrUrl: '', // 图片地址
c9d45ef5   刘淇   商户券 有效期
49
50
        single: '',
        startTime:''
36884ffd   刘淇   打印
51
52
53
54
55
56
      }
    },
    onLoad(params) {
      wx.showShareMenu({
        withShareTicket: true
      })
9bac797d   刘淇   卡券发放
57
58
59
60
61
62
63
64
65
      console.log(params)
      let option = params
      this.cardRelParkNo = option.cardRelParkNo
      this.cardTypeName = option.cardTypeName
      this.cardRuleName = option.cardRuleName
      this.plName = option.plName
      this.price = option.price
      this.cardNum = option.cardNum
      this.getCouponStaticQR()
36884ffd   刘淇   打印
66
67
68
    },
    onShow() {
      var me = this;
36884ffd   刘淇   打印
69
    },
c9d45ef5   刘淇   商户券 有效期
70
71
72
73
74
75
76
    mounted() {
      setTimeout(() => {
      this.startTime = Date.now()
      this.single = Date.now()
  
      },500)
    },
9bac797d   刘淇   卡券发放
77
    computed: {},
36884ffd   刘淇   打印
78
    methods: {
9bac797d   刘淇   卡券发放
79
      changeValue(value) {
fc8d2d1a   刘淇   打印
80
81
        this.numberValue = value
      },
9bac797d   刘淇   卡券发放
82
83
84
85
86
      getCouponStaticQR() {
        let that = this
        let paramsData = {
          cardRelParkNo: this.cardRelParkNo,
          codeType: '2',
c9d45ef5   刘淇   商户券 有效期
87
          deadline: this.deadline
9bac797d   刘淇   卡券发放
88
89
90
91
92
93
94
95
96
97
        }
        // 首页信息获取 接口
        that.$myRequest({
          url: that.$common.getCouponStaticQR,
          method: 'POST',
          data: that.$common.requestSign(paramsData)
        }).then(res => {
          console.log(res)
          that.qrUrl = res.data.qrUrl
          console.log(that.qrUrl)
36884ffd   刘淇   打印
98
99
        })
      },
9bac797d   刘淇   卡券发放
100
101
102
103
104
105
106
      //**生成二维码**//
      qrFun: function (text) {
        this.qrShow = true
        uQRCode.make({
          canvasId: 'qrcode',
          componentInstance: this,
          text: text,
1fa597c2   刘淇   二维码大小
107
          size: 130,
9bac797d   刘淇   卡券发放
108
109
110
111
112
113
114
115
          margin: 0,
          backgroundColor: '#ffffff',
          foregroundColor: '#000000',
          fileType: 'jpg',
          errorCorrectLevel: uQRCode.errorCorrectLevel.H,
          success: res => {
          }
        })
36884ffd   刘淇   打印
116
      },
9bac797d   刘淇   卡券发放
117
      changeTime: function () {
c9d45ef5   刘淇   商户券 有效期
118
        this.deadline = this.single
9bac797d   刘淇   卡券发放
119
        this.getCouponStaticQR()
1fa597c2   刘淇   二维码大小
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
      },
      // 小程序保存图片
      savePosterPath(url) {
        uni.downloadFile({
          url,
          success: (resFile) => {
          console.log(resFile, "resFile");
        if (resFile.statusCode === 200) {
          uni.getSetting({
            success: (res) => {
            if (!res.authSetting["scope.writePhotosAlbum"]) {
            uni.authorize({
              scope: "scope.writePhotosAlbum",
              success: () => {
              uni.saveImageToPhotosAlbum({
              filePath: resFile.tempFilePath,
              success: (res) => {
              return uni.showToast({
                title: "保存成功!",
              });
          },
            fail: (res) => {
              return uni.showToast({
                title: res.errMsg,
              });
            },
            complete: (res) => {},
          });
          },
            fail: () => {
              uni.showModal({
                title: "您已拒绝获取相册权限",
                content: "是否进入权限管理,调整授权?",
                success: (res) => {
                if (res.confirm) {
                uni.openSetting({
                  success: (res) => {
                  console.log(res.authSetting);
              },
              });
              } else if (res.cancel) {
                return uni.showToast({
                  title: "已取消!",
                });
              }
            },
            });
            },
          });
          } else {
            uni.saveImageToPhotosAlbum({
              filePath: resFile.tempFilePath,
              success: (res) => {
              return uni.showToast({
                title: "保存成功!",
              });
          },
            fail: (res) => {
              return uni.showToast({
                title: res.errMsg,
              });
            },
            complete: (res) => {},
          });
          }
        },
          fail: (res) => {},
        });
        } else {
          return uni.showToast({
            title: resFile.errMsg,
          });
        }
      },
        fail: (res) => {
          return uni.showToast({
            title: res.errMsg,
          });
        },
      });
      },
36884ffd   刘淇   打印
201
202
203
204
205
    }
  }
  </script>
  
  <style lang="scss" scoped>
36884ffd   刘淇   打印
206
  
36884ffd   刘淇   打印
207
208
  
  </style>