소스 검색

新增消息订阅功能

xiaoxin 2 년 전
부모
커밋
56f3279d06
4개의 변경된 파일73개의 추가작업 그리고 19개의 파일을 삭제
  1. 35 9
      pages/index/index.vue
  2. 35 7
      unpackage/dist/dev/mp-weixin/pages/index/index.js
  3. 1 1
      unpackage/dist/dev/mp-weixin/util/api.js
  4. 2 2
      util/api.js

+ 35 - 9
pages/index/index.vue

@@ -129,7 +129,13 @@ import getLessLimitSizeImage from '@/util/imageCompress.js'
 onMounted(() => {
 	const accredit = uni.getStorageSync('accredit')
 	if (accredit) {
-		submit()
+		uni.login({
+			//使用微信登录
+			provider: 'weixin',
+			success: (res) => {
+				submit(res.code)
+			}
+		})
 	}
 })
 //画板边长默认是屏幕宽度,正方形画布
@@ -261,7 +267,7 @@ const filePicker = ref(null)
 const popup = ref(null)
 
 // 模版id
-const templateOrder = ref('I3o8CRAiaaNbug3Ukkmv1t-pCIbzxU8OicqMWvdR9lc')
+const templateOrder = ref('I3o8CRAiaaNbug3Ukkmv1o3S7l1FZlAKMUAJzIJ4zhs')
 
 // 点击弹窗 我知道了 按钮回调
 const handleSubscribe = () => {
@@ -270,12 +276,12 @@ const handleSubscribe = () => {
 	uni.getSetting({
 		withSubscriptions: true,
 		success: (res) => {
-			// console.log(res)
-			if (res.subscriptionsSetting[templateOrder.value] !== 'reject') {
+			console.log(res)
+			if (res.subscriptionsSetting.mainSwitch) {
 				uni.requestSubscribeMessage({
 					tmplIds: [templateOrder.value],
 					success: (res) => {
-						// console.log(res)
+						console.log(res)
 						if (res[templateOrder.value] !== 'reject') {
 							console.log('成功')
 							// uni.showToast({
@@ -288,6 +294,19 @@ const handleSubscribe = () => {
 							// 	title:"订阅失败",
 							// 	icon:'fail'
 							// })
+							uni.showModal({
+								content: '当前没有订阅,是否去设置打开?',
+								confirmText: '确认',
+								cancelText: '取消',
+								success: (res) => {
+									if (res.confirm) {
+										uni.openSetting({
+											success: (res) => {}
+										})
+									} else {
+									}
+								}
+							})
 						}
 					},
 					fail(err) {
@@ -297,7 +316,7 @@ const handleSubscribe = () => {
 				})
 			} else {
 				uni.showModal({
-					content: '当前没有订阅,是否去设置打开?',
+					content: '当前订阅总开关关闭,是否去设置打开?',
 					confirmText: '确认',
 					cancelText: '取消',
 					success: (res) => {
@@ -360,7 +379,13 @@ const handleSubmit = () => {
 				content: '确认提交吗',
 				success: (res) => {
 					if (res.confirm) {
-						submit()
+						uni.login({
+							//使用微信登录
+							provider: 'weixin',
+							success: (res) => {
+								submit(res.code)
+							}
+						})
 					} else if (res.cancel) {
 					}
 				}
@@ -470,7 +495,7 @@ const handleValidate = () => {
 }
 
 // 请求提交接口回调
-const submit = async () => {
+const submit = async (code) => {
 	const bProduct = []
 	productType.value.forEach((item) => {
 		bProduct.push(hobby.value[item].text)
@@ -507,7 +532,8 @@ const submit = async () => {
 			// 是否授权
 			licensing: isAzt.value,
 			// 加入的控标参数
-			parameters: projectParams.value
+			parameters: projectParams.value,
+			code
 		}
 	})
 	// console.log(res)

+ 35 - 7
unpackage/dist/dev/mp-weixin/pages/index/index.js

@@ -24,7 +24,13 @@ const _sfc_main = {
     common_vendor.onMounted(() => {
       const accredit = common_vendor.index.getStorageSync("accredit");
       if (accredit) {
-        submit();
+        common_vendor.index.login({
+          //使用微信登录
+          provider: "weixin",
+          success: (res) => {
+            submit(res.code);
+          }
+        });
       }
     });
     const cw = common_vendor.index.getSystemInfoSync().windowWidth;
@@ -125,20 +131,35 @@ const _sfc_main = {
     };
     const filePicker = common_vendor.ref(null);
     const popup = common_vendor.ref(null);
-    const templateOrder = common_vendor.ref("I3o8CRAiaaNbug3Ukkmv1t-pCIbzxU8OicqMWvdR9lc");
+    const templateOrder = common_vendor.ref("I3o8CRAiaaNbug3Ukkmv1o3S7l1FZlAKMUAJzIJ4zhs");
     const handleSubscribe = () => {
       popup.value.close();
       common_vendor.index.getSetting({
         withSubscriptions: true,
         success: (res) => {
-          if (res.subscriptionsSetting[templateOrder.value] !== "reject") {
+          console.log(res);
+          if (res.subscriptionsSetting.mainSwitch) {
             common_vendor.index.requestSubscribeMessage({
               tmplIds: [templateOrder.value],
               success: (res2) => {
+                console.log(res2);
                 if (res2[templateOrder.value] !== "reject") {
                   console.log("成功");
                 } else {
                   console.log("拒绝2");
+                  common_vendor.index.showModal({
+                    content: "当前没有订阅,是否去设置打开?",
+                    confirmText: "确认",
+                    cancelText: "取消",
+                    success: (res3) => {
+                      if (res3.confirm) {
+                        common_vendor.index.openSetting({
+                          success: (res4) => {
+                          }
+                        });
+                      }
+                    }
+                  });
                 }
               },
               fail(err) {
@@ -148,7 +169,7 @@ const _sfc_main = {
             });
           } else {
             common_vendor.index.showModal({
-              content: "当前没有订阅,是否去设置打开?",
+              content: "当前订阅总开关关闭,是否去设置打开?",
               confirmText: "确认",
               cancelText: "取消",
               success: (res2) => {
@@ -207,7 +228,13 @@ const _sfc_main = {
             content: "确认提交吗",
             success: (res) => {
               if (res.confirm) {
-                submit();
+                common_vendor.index.login({
+                  //使用微信登录
+                  provider: "weixin",
+                  success: (res2) => {
+                    submit(res2.code);
+                  }
+                });
               } else if (res.cancel)
                 ;
             }
@@ -312,7 +339,7 @@ const _sfc_main = {
       }
       return true;
     };
-    const submit = async () => {
+    const submit = async (code) => {
       const bProduct = [];
       productType.value.forEach((item) => {
         bProduct.push(hobby.value[item].text);
@@ -348,7 +375,8 @@ const _sfc_main = {
           // 是否授权
           licensing: isAzt.value,
           // 加入的控标参数
-          parameters: projectParams.value
+          parameters: projectParams.value,
+          code
         }
       });
       if (res.success && res.code == 1) {

+ 1 - 1
unpackage/dist/dev/mp-weixin/util/api.js

@@ -1,6 +1,6 @@
 "use strict";
 const common_vendor = require("../common/vendor.js");
-const BASE_URL = "http://172.16.20.80:8888/reporting";
+const BASE_URL = "https://jiangxih3cpartner.com/reporting";
 const myRequest = (options) => {
   common_vendor.index.showLoading({
     title: "加载中",

+ 2 - 2
util/api.js

@@ -1,8 +1,8 @@
 // 测试服务器
-const BASE_URL = 'http://172.16.20.80:8888/reporting'
+// const BASE_URL = 'http://172.16.20.80:8888/reporting'
 
 // 正式服务器
-// const BASE_URL = "https://jiangxih3cpartner.com/reporting"
+const BASE_URL = "https://jiangxih3cpartner.com/reporting"
 export const myRequest = (options) => {
 	uni.showLoading({
 		title: "加载中",