知识付费微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

390 lines
8.9 KiB

1 year ago
  1. <template>
  2. <view class="index">
  3. <view class="top">
  4. <view class="content">
  5. <image class="content-img" src="../../static/top.png" />
  6. <view class="content-left">
  7. <u-row style="margin: 10rpx;">
  8. <u-col>
  9. AI头条3.0半AI写作简单易操作
  10. </u-col>
  11. </u-row>
  12. <u-row justify="space-between" style="margin: 20rpx; font-size: 12px;">
  13. <u-col span="4">
  14. 级别:初级
  15. </u-col>
  16. <u-col span="4">
  17. 18人学习
  18. </u-col>
  19. </u-row>
  20. <u-row justify="space-between" style="margin: 10rpx; font-size: 16px;">
  21. <u-col span="4" style="color: #ff7800;">
  22. 4.00
  23. </u-col>
  24. <!-- <u-col span="4" style="text-decoration:line-through">
  25. 29.90
  26. </u-col> -->
  27. </u-row>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="cell">
  32. <view class="cell-box">
  33. <view>
  34. 无法查看资源内容请购买!
  35. </view>
  36. </view>
  37. </view>
  38. <view class="book">
  39. <view class="book-text">
  40. <view style="padding-top: 20rpx;font-size: 14px;">资源介绍</view>
  41. <image class="book-img" src="../../static/top.png" />
  42. <view>
  43. AI头条3.0--半A1写作变现新玩法
  44. </view>
  45. <view>
  46. 在当今 AI 飞速发展的时代今日头条这个存在已久的平台也焕发出了新的活力A1头条
  47. 3.0项目为你带来全新的变现机遇门槛极低无需粉丝基础新号即可直接上手操作仅需一部手机让你随时随地开启赚钱之旅
  48. <view></view>
  49. 这个项目的粉丝和收益转化率极为可观经过实测众多账号在发布文章后的短短两三天内粉丝量就能轻松破千无论你是新手小白还是有经验的创作者都能在这个项目中找到属于自己的机会
  50. </view>
  51. </view>
  52. </view>
  53. <view class="bottom-flex">
  54. <view class="icon">
  55. <u-icon name="server-man"
  56. size="40rpx"
  57. ></u-icon>
  58. 客服
  59. </view>
  60. <view class="icon">
  61. <u-number-box
  62. style="margin: 0 auto;"
  63. v-model="registerForm.num"
  64. :min="1">
  65. <view slot="minus" class="minus">
  66. <u-icon name="minus" size="12"></u-icon>
  67. </view>
  68. <view slot="plus" class="plus">
  69. <u-icon name="plus" color="#FFFFFF" size="12"></u-icon>
  70. </view>
  71. </u-number-box>
  72. </view>
  73. <view class="button">
  74. <view class="button-right">
  75. <view>
  76. 立即购买 ({{ price * registerForm.num }})
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. // wxf173d7bec0f1bbe0
  85. import api from '@/plugins/api.js'
  86. export default {
  87. data() {
  88. return {
  89. registerForm: {
  90. num: 1
  91. },
  92. price : 4,
  93. }
  94. },
  95. onLoad() {
  96. // if(this.GetQueryString('code')){ //路径上面有code说明微信已授权
  97. // this.code = this.GetQueryString('code');
  98. // //直接去登录发起请求
  99. // this.toWxLogin(this.code)
  100. // }else{
  101. // this.getwx_authorize()
  102. // }
  103. },
  104. methods: {
  105. valChange() {},
  106. getwx_authorize() {
  107. // let vid = uni.getStorageSync("ivcode");
  108. let redirect_uri = encodeURIComponent(this.VITE_REDIRECT_URI);
  109. let appid = this.VITE_APPID;
  110. window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid +
  111. '&redirect_uri=' + redirect_uri +
  112. '&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect' + '&t=' + new Date().getTime();
  113. },
  114. //获取url中参数的方法
  115. GetQueryString(name) {
  116. var url = window.location.href;
  117. try {
  118. var cs = url.split('?')[1]; //获取?之后的参数字符串
  119. var cs_arr = cs.split('&'); //参数字符串分割为数组
  120. for (var i = 0; i < cs_arr.length; i++) { //遍历数组,拿到json对象
  121. if (cs_arr[i].split('=')[0] == name) {
  122. return cs_arr[i].split('=')[1];
  123. }
  124. }
  125. return "";
  126. } catch {
  127. return "";
  128. }
  129. },
  130. clickService() {
  131. uni.makePhoneCall({
  132. phoneNumber: this.phone,
  133. success: () => {},
  134. fail: () => {}
  135. });
  136. },
  137. //微信登录
  138. toWxLogin(code) {
  139. console.log(code);
  140. api('wxLogin', {
  141. code
  142. }, res => {
  143. if (res.code == 200) {
  144. if (this.type == 0) {
  145. this.price = res.result.money
  146. } else {
  147. this.price = res.result.price
  148. }
  149. localStorage.setItem("token", res.result.token)
  150. localStorage.setItem("userInfo", JSON.stringify(res.result.userInfo))
  151. } else {
  152. location.href = this.VITE_REDIRECT_URI
  153. }
  154. })
  155. },
  156. Register() {
  157. if (!localStorage.getItem('token')) {
  158. this.getwx_authorize()
  159. }
  160. if (this.registerForm.name.trim() === '') return uni.$u.toast('请输入姓名')
  161. else if (this.registerForm.phone.trim() === '') return uni.$u.toast('请输入手机号')
  162. if (!/^1[3-9]\d{9}$/.test(this.registerForm.phone)) {
  163. return uni.$u.toast('手机号格式不合法')
  164. }
  165. api('createOrder', {
  166. ...this.registerForm,
  167. type: this.type
  168. }, res => {
  169. if (res.code == 200) {
  170. this.chooseWXPay(res.result)
  171. }
  172. })
  173. },
  174. chooseWXPay(res) {
  175. let self = this
  176. self.$jweixin.config({
  177. debug: false,
  178. appId: res.appId, //必填
  179. jsApiList: ['chooseWXPay']
  180. });
  181. self.$jweixin.ready(function() {
  182. self.$jweixin.chooseWXPay({
  183. appId: res.appId,
  184. timestamp: res
  185. .timeStamp, // 支付签名时间戳,注意微信 jssdk 中的所有使用 timestamp 字段均为小写。但最新版的支付后台生成签名使用的 timeStamp 字段名需大写其中的 S 字符
  186. nonceStr: res.nonceStr, // 支付签名随机串,不长于 32 位
  187. package: res.packageValue, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
  188. signType: res.signType, // 微信支付V3的传入 RSA ,微信支付V2的传入格式与V2统一下单的签名格式保持一致
  189. paySign: res.paySign, // 支付签名
  190. success: function(res) {
  191. // 支付成功后的回调函数
  192. uni.showToast({
  193. icon: 'none',
  194. title: '支付成功',
  195. });
  196. self.registerForm.name = ''
  197. self.registerForm.phone = ''
  198. }
  199. });
  200. });
  201. self.$jweixin.error(function(res) {
  202. uni.showToast({
  203. icon: 'none',
  204. title: '支付失败了',
  205. });
  206. });
  207. },
  208. }
  209. }
  210. </script>
  211. <style scoped lang="scss">
  212. .index {
  213. background-color: #ccc;
  214. .bottom-flex{
  215. position: fixed;
  216. left: 0;
  217. bottom: 0;
  218. width: 100%;
  219. display: flex;
  220. height: 100rpx;
  221. padding: 10rpx 0;
  222. background-color: #fff;
  223. justify-content: space-around;
  224. .icon{
  225. font-size: 26rpx;
  226. display: flex;
  227. flex-direction: column;
  228. justify-content: center;
  229. align-items: center;
  230. }
  231. }
  232. }
  233. .top {
  234. padding-top: var(--status-bar-height);
  235. position: relative;
  236. height: 230rpx;
  237. background-color: #000;
  238. }
  239. .content {
  240. position: absolute;
  241. top: 20rpx;
  242. width: 100%;
  243. height: 250rpx;
  244. }
  245. .content-img {
  246. position: absolute;
  247. top: 20rpx;
  248. left: 20rpx;
  249. width: 220rpx;
  250. height: 160rpx;
  251. border-radius: 10rpx;
  252. }
  253. .content-left {
  254. position: absolute;
  255. color: #fff;
  256. font-size: 14px;
  257. left: 35%;
  258. top: 20rpx;
  259. line-height: 50rpx;
  260. }
  261. .cell {
  262. display: flex;
  263. justify-content: center;
  264. align-items: center;
  265. height: 140rpx;
  266. background-color: #fff;
  267. width: 100%;
  268. }
  269. .cell-box {
  270. display: flex;
  271. width: 90%;
  272. background-color: rgb(253, 194, 4);
  273. height: 70rpx;
  274. border-radius: 10rpx;
  275. font-size: 12px;
  276. justify-content: center;
  277. align-items: center;
  278. }
  279. .book {
  280. margin-top: 20rpx;
  281. min-height: 600rpx;
  282. background-color: #fff;
  283. }
  284. .book-text {
  285. width: 94%;
  286. margin-left: 3%;
  287. min-height: 700rpx;
  288. font-size: 13px;
  289. line-height: 40rpx;
  290. padding-bottom: 100rpx;
  291. }
  292. .book-img {
  293. padding-top: 20rpx;
  294. width: 100%;
  295. height: 300rpx;
  296. }
  297. .button {
  298. position: relative;
  299. display: flex;
  300. top: 10rpx;
  301. width: 350rpx;
  302. height: 80%;
  303. font-size: 12px;
  304. }
  305. .button-left {
  306. display: flex;
  307. justify-content: center;
  308. align-items: center;
  309. flex: 1;
  310. height: 100%;
  311. background-color: rgb(253, 194, 5);
  312. // border-top-left-radius: 50rpx;
  313. // border-bottom-left-radius: 50rpx;
  314. }
  315. .button-right {
  316. display: flex;
  317. justify-content: center;
  318. align-items: center;
  319. flex: 1;
  320. height: 100%;
  321. background-color: rgb(51, 51, 51);
  322. // border-top-right-radius: 50rpx;
  323. // border-bottom-right-radius: 50rpx;
  324. border-radius: 50rpx;
  325. color: #fff;
  326. }
  327. // 步进器
  328. .minus {
  329. width: 22px;
  330. height: 22px;
  331. border-width: 1px;
  332. border-color: #E6E6E6;
  333. border-style: solid;
  334. border-top-left-radius: 100px;
  335. border-top-right-radius: 100px;
  336. border-bottom-left-radius: 100px;
  337. border-bottom-right-radius: 100px;
  338. @include flex;
  339. justify-content: center;
  340. align-items: center;
  341. }
  342. .input {
  343. padding: 0 10px;
  344. margin: 0 10rpx;
  345. }
  346. .plus {
  347. width: 22px;
  348. height: 22px;
  349. background-color: rgb(253, 194, 5);
  350. border-radius: 50%;
  351. /* #ifndef APP-NVUE */
  352. display: flex;
  353. /* #endif */
  354. justify-content: center;
  355. align-items: center;
  356. }
  357. </style>