DirectDetail.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="hb column">
  3. <view class="justify-between align-center p44 m20 colorf bgmap" >
  4. <view class="justify-center">
  5. <view>
  6. <view class="fs48 bold">¥{{DirectDetail.couponPrice}}</view>
  7. </view>
  8. <view class="ml60">
  9. <view>{{DirectDetail.couponName}}</view>
  10. <view class="fs24 mt16">可与优惠卷叠加使用</view>
  11. </view>
  12. </view>
  13. <!-- <view class="share-box" v-if="companytoken!=null">
  14. <view class="bgf base-price plr28 ptb12 radius40">分享</view>
  15. <button class="share" data-name="shareBtn" open-type="share">分享</button>
  16. </view> -->
  17. <view class="bgf base-price plr18 ptb12 radius40" @click="payDic">¥{{DirectDetail.couponPrice}}购买</view>
  18. </view>
  19. <view>
  20. <u-modal :show="showpay" :title="title" :content='content' @confirm='tocoupon'></u-modal>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import { payCashCoupon} from '@/api/coupon'
  26. import { loginByMiniApp} from '@/api/user'
  27. export default {
  28. data(){
  29. return{
  30. imageMap: 'https://bjczwh.oss-cn-beijing.aliyuncs.com/app/shop/images/Direct-sel.png',
  31. DirectDetail:[],
  32. companyUserId:'',
  33. companytoken:uni.getStorageSync('CompanyUserToken'),
  34. showpay:false,
  35. title:'支付成功',
  36. content:'立减金购买成功,请到我的-优惠卷(立减金)查看立减金!',
  37. companyId:""
  38. }
  39. },
  40. //发送给朋友
  41. onShareAppMessage() {
  42. return {
  43. title: this.DirectDetail.nmae,
  44. path: '/pages_company/order/DirectDetail?companyUserId='+this.companyUserId
  45. +"&item="+JSON.stringify(this.DirectDetail)
  46. }
  47. },
  48. onLoad(option) {
  49. this.companyUserId=option.companyUserId
  50. this.companyId=option.companyId
  51. console.log(JSON.parse(option.item))
  52. this.DirectDetail=JSON.parse(option.item)
  53. if(!uni.getStorageSync('AppToken')||uni.getStorageSync('AppToken')==null){
  54. this.gologin()
  55. }
  56. },
  57. methods:{
  58. gologin(){
  59. let provider = 'weixin'
  60. uni.login({
  61. provider: provider,
  62. success: async loginRes => {
  63. console.log(loginRes)
  64. uni.getUserInfo({
  65. provider: provider,
  66. success: (infoRes)=> {
  67. uni.showToast({
  68. title: '处理中...',
  69. icon: 'loading'
  70. });
  71. loginByMiniApp({
  72. code: loginRes.code,
  73. encryptedData:infoRes.encryptedData,
  74. iv:infoRes.iv,
  75. appId:wx.getAccountInfoSync().miniProgram.appId,
  76. }).then(res=>{
  77. uni.hideLoading();
  78. if (res.code == 200) {
  79. uni.setStorageSync('AppToken',res.token);
  80. uni.setStorageSync('userInfo',JSON.stringify(res.user));
  81. } else {
  82. uni.showToast({
  83. title: res.msg,
  84. icon: 'none'
  85. });
  86. }
  87. })
  88. }
  89. });
  90. }
  91. })
  92. },
  93. payDic(){
  94. const data={
  95. id:this.DirectDetail.id,
  96. couponId:this.DirectDetail.couponId,
  97. companyId:this.companyId,
  98. companyUserId:this.companyUserId,
  99. userId:uni.getStorageSync('userInfo').userId
  100. }
  101. payCashCoupon(data).then(res=>{
  102. let that =this
  103. if(res.code==200){
  104. console.log(res)
  105. uni.requestPayment({
  106. provider: 'wxpay',
  107. timeStamp: res.result.timeStamp,
  108. nonceStr: res.result.nonceStr,
  109. package: res.result.packageValue,
  110. signType: res.result.signType,
  111. paySign: res.result.paySign,
  112. success: function(res) {
  113. uni.hideLoading();
  114. console.log(that.showpay)
  115. that.showpay=true
  116. uni.showToast({
  117. icon:'success',
  118. title: "支付成功",
  119. });
  120. },
  121. fail: function(err) {
  122. console.log('fail:' + JSON.stringify(err));
  123. uni.hideLoading();
  124. uni.showToast({
  125. icon:'none',
  126. title: '用户取消支付!',
  127. });
  128. console.log(that.showpay)
  129. }
  130. });
  131. }else{
  132. uni.showToast({
  133. icon:'none',
  134. title: res.msg,
  135. });
  136. }
  137. })
  138. },
  139. tocoupon(){
  140. uni.navigateTo({
  141. url:'/pages_shopping/shopping/myCoupon?tabsact='+3
  142. })
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .bgmap{
  149. background: url('https://bjczwh.oss-cn-beijing.aliyuncs.com/app/shop/images/Direct-sel.png');
  150. background-size: cover;
  151. }
  152. .share-box{
  153. width: 120upx;
  154. height: 46upx;
  155. border: 1px solid #2BC7B9;
  156. border-radius: 23upx;
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. position: relative;
  161. .share{
  162. display: inline-block;
  163. position: absolute;
  164. top: 0;
  165. left: 0;
  166. width: 100%;
  167. height: 100%;
  168. opacity: 0;
  169. }
  170. }
  171. </style>