diff --git a/pages.json b/pages.json index ec64263..adbffc6 100644 --- a/pages.json +++ b/pages.json @@ -283,13 +283,14 @@ "path": "pages/goods/details", "name": "goodsDetails", "style": { - "navigationBarTitleText": "", + "navigationBarTitleText": "商品详情", + "navigationBarTextStyle":"white", "titleNView": { - "backgroundColor": "#FFFFFF", + "backgroundColor": "#8b64fd", "type": "transparent", "buttons": [{ "text": "分享", - "fontSize": "12", + "fontSize": "14", "color": "#555555" }] } diff --git a/pages/goods/details.vue b/pages/goods/details.vue index 582889b..899f8f1 100644 --- a/pages/goods/details.vue +++ b/pages/goods/details.vue @@ -28,7 +28,9 @@ - {{goodsObj.specal_tags.is_allow_values}} + + {{goodsObj.specal_tags.is_allow_values}} + {{goodsObj.specal_tags.is_self}} {{goodsObj.name}} @@ -175,9 +177,7 @@ - - 确定 - + 确定 @@ -189,6 +189,9 @@ managesCoupons } from '@/apis/interfaces/goods' import userAuth from '@/public/userAuth' + import UniShare from 'uni_modules/uni-share/js_sdk/uni-share.js' + const uniShare = new UniShare() + import {config} from '@/apis/index.js' export default { data() { return { @@ -210,6 +213,17 @@ this.coupons = res.coupons }) }, + onBackPress({ + from + }) { + console.log(from); + if (from == 'backbutton') { + this.$nextTick(function() { + uniShare.hide() + }) + return uniShare.isShow; + } + }, methods: { // 提交购买单 buyGoods() { @@ -298,6 +312,40 @@ // 查看保障服务-隐藏 serveClose() { this.$refs.servePopup.close() + }, + // 顶部菜单点击了分享功能 + onNavigationBarButtonTap() { + console.log('点击了分享功能。。。') + uniShare.show({ + content: { //公共的分享参数配置 类型(type)、链接(herf)、标题(title)、summary(描述)、imageUrl(缩略图) + type: 0, + href: 'https://www.lianshang.vip/app?', + title: '链商星球,共创未来,一起搭建链商经济的世界~', + summary: '链商星球app你值得拥有~天天签到领福利~', + imageUrl: config.apiUrls+'images/top_logo.png' + }, + menus: [{ + "img": "/static/icons/payWay_icon_00.png", + "text": "微信好友", + "share": { //当前项的分享参数配置。可覆盖公共的配置如下:分享到微信小程序,配置了type=5 + "provider": "weixin", + "scene": "WXSceneSession" + } + }, + { + "img": "/static/icons/share-pyq.png", + "text": "微信朋友圈", + "share": { + "provider": "weixin", + "scene": "WXSenceTimeline" + } + } + ], + cancelText: "取消分享", + }, e => { //callback + console.log(uniShare.isShow); + console.log(e); + }) } } } @@ -353,7 +401,7 @@ .title-hot { display: inline-block; - background-image: linear-gradient(to left,#fee195,#fee195); + background-image: linear-gradient(to left, #fee195, #fee195); font-size: 24rpx; border-radius: 50rpx; padding: 0 10rpx; diff --git a/static/icons/share-pyq.png b/static/icons/share-pyq.png new file mode 100644 index 0000000..1a075c9 Binary files /dev/null and b/static/icons/share-pyq.png differ diff --git a/static/icons/share-wx.png b/static/icons/share-wx.png new file mode 100644 index 0000000..7819551 Binary files /dev/null and b/static/icons/share-wx.png differ diff --git a/uni_modules/uni-share/changelog.md b/uni_modules/uni-share/changelog.md new file mode 100644 index 0000000..e3cd23f --- /dev/null +++ b/uni_modules/uni-share/changelog.md @@ -0,0 +1,14 @@ +## 2.0.0(2021-10-14) +支持监听返回操作(如:物理返回,全面屏手机侧滑)关闭分享弹窗 +## 1.0.6(2021-08-25) +兼容vue3 +## 1.0.5(2021-08-05) +优化代码实现,修改原来用`eval()`函数实现的逻辑 +## 1.0.4(2021-06-07) +为符合苹果应用市场的审核,只显示存在对应的分享客户端的选项。如:配置包含微信分享,但是用户手机上并没有安装微信,就不显示微信分享。 +## 1.0.2(2021-05-06) +修复错误的提示:“打包时未添加oauth模块” +## 1.0.1(2021-04-30) +新增完整示例 +## 1.0.0(2021-04-28) +第1版发布 diff --git a/uni_modules/uni-share/js_sdk/uni-image-menu.js b/uni_modules/uni-share/js_sdk/uni-image-menu.js new file mode 100644 index 0000000..a15a846 --- /dev/null +++ b/uni_modules/uni-share/js_sdk/uni-image-menu.js @@ -0,0 +1,203 @@ +var nvMask, nvImageMenu; +class NvImageMenu { + constructor(arg) { + this.isShow = false + } + show({ + list, + cancelText + }, callback) { + if (!list) { + list = [{ + "img": "/static/sharemenu/wechatfriend.png", + "text": "图标文字" + }] + } + //以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心 + var screenWidth = plus.screen.resolutionWidth + //以360px宽度屏幕为例,上下左右边距及2排按钮边距留25像素,图标宽度55像素,同行图标间的间距在360宽的屏幕是30px,但需要动态计算,以此原则计算4列图标分别的left位置 + //图标下的按钮文字距离图标5像素,文字大小12像素 + //底部取消按钮高度固定为44px + //TODO 未处理横屏和pad,这些情况6个图标应该一排即可 + var margin = 20, + iconWidth = 60, + icontextSpace = 5, + textHeight = 12 + var left1 = margin / 360 * screenWidth + var iconSpace = (screenWidth - (left1 * 2) - (iconWidth * 4)) / 3 //屏幕宽度减去左右留白间距,再减去4个图标的宽度,就是3个同行图标的间距 + if (iconSpace <= 5) { //屏幕过窄时,缩小边距和图标大小,再算一次 + margin = 15 + iconWidth = 40 + left1 = margin / 360 * screenWidth + iconSpace = (screenWidth - (left1 * 2) - (iconWidth * 4)) / 3 //屏幕宽度减去左右留白间距,再减去4个图标的宽度,就是3个同行图标的间距 + } + var left2 = left1 + iconWidth + iconSpace + var left3 = left1 + (iconWidth + iconSpace) * 2 + var left4 = left1 + (iconWidth + iconSpace) * 3 + var top1 = left1 + var top2 = top1 + iconWidth + icontextSpace + textHeight + left1 + + const TOP = { + top1, + top2 + }, + LEFT = { + left1, + left2, + left3, + left4 + }; + + nvMask = new plus.nativeObj.View("nvMask", { //先创建遮罩层 + top: '0px', + left: '0px', + height: '100%', + width: '100%', + backgroundColor: 'rgba(0,0,0,0.2)' + }); + nvImageMenu = new plus.nativeObj.View("nvImageMenu", { //创建底部图标菜单 + bottom: '0px', + left: '0px', + height: (iconWidth + textHeight + 2 * margin) * Math.ceil(list.length / 4) + 44 + + 'px', //'264px', + width: '100%', + backgroundColor: 'rgb(255,255,255)' + }); + nvMask.addEventListener("click", () => { //处理遮罩层点击 + // console.log('处理遮罩层点击'); + this.hide() + callback({ + event: "clickMask" + }) + }) + let myList = [] + list.forEach((item, i) => { + myList.push({ + tag: 'img', + src: item.img, + position: { + top: TOP['top' + (parseInt(i / 4) + 1)], + left: LEFT['left' + (1 + i % 4)], + width: iconWidth, + height: iconWidth + } + }) + myList.push({ + tag: 'font', + text: item.text, + textStyles: { + size: textHeight + }, + position: { + top: TOP['top' + (parseInt(i / 4) + 1)] + iconWidth + icontextSpace, + left: LEFT['left' + (1 + i % 4)], + width: iconWidth, + height: textHeight + } + }) + }) + + //绘制底部图标菜单的内容 + nvImageMenu.draw([{ + tag: 'rect', //菜单顶部的分割灰线 + color: '#e7e7e7', + position: { + top: '0px', + height: '1px' + } + }, + { + tag: 'font', + text: cancelText, //底部取消按钮的文字 + textStyles: { + size: '14px' + }, + position: { + bottom: '0px', + height: '44px' + } + }, + { + tag: 'rect', //底部取消按钮的顶部边线 + color: '#e7e7e7', + position: { + bottom: '45px', + height: '1px' + } + }, + ...myList + ]) + nvMask.show() + nvImageMenu.show() + // 开始动画 + /* + plus.nativeObj.View.startAnimation({ + type: 'slide-in-bottom', + duration: 300 + }, nvImageMenu, {}, function() { + console.log('plus.nativeObj.View.startAnimation动画结束'); + // 关闭原生动画 + plus.nativeObj.View.clearAnimation(); + nvImageMenu.show() + }); + */ + + + this.isShow = true + nvImageMenu.addEventListener("click", e => { //处理底部图标菜单的点击事件,根据点击位置触发不同的逻辑 + // console.log("click menu"+JSON.stringify(e)); + if (e.screenY > plus.screen.resolutionHeight - 44) { //点击了底部取消按钮 + // callback({event:"clickCancelButton"}) + this.hide() + } else if (e.clientX < 5 || e.clientX > screenWidth - 5 || e.clientY < 5) { + //屏幕左右边缘5像素及菜单顶部5像素不处理点击 + } else { //点击了图标按钮 + var iClickIndex = -1 //点击的图标按钮序号,第一个图标按钮的index为0 + var iRow = e.clientY < (top2 - (left1 / 2)) ? 0 : 1 + var iCol = -1 + if (e.clientX < (left2 - (iconSpace / 2))) { + iCol = 0 + } else if (e.clientX < (left3 - (iconSpace / 2))) { + iCol = 1 + } else if (e.clientX < (left4 - (iconSpace / 2))) { + iCol = 2 + } else { + iCol = 3 + } + if (iRow == 0) { + iClickIndex = iCol + } else { + iClickIndex = iCol + 4 + } + // console.log("点击按钮的序号: " + iClickIndex); + // if (iClickIndex >= 0 && iClickIndex <= 5) { //处理具体的点击逻辑,此处也可以自行定义逻辑。如果增减了按钮,此处也需要跟着修改 + // } + callback({ + event: "clickMenu", + index: iClickIndex + }) + } + }) + /* nvImageMenu.addEventListener("touchstart", function(e) { + if (e.screenY > (plus.screen.resolutionHeight - 44)) { + //TODO 这里可以处理按下背景变灰的效果 + } + }) + nvImageMenu.addEventListener("touchmove", function(e) { + //TODO 这里可以处理按下背景变灰的效果 + if (e.screenY > plus.screen.resolutionHeight - 44) {} + }) + nvImageMenu.addEventListener("touchend", function(e) { + //TODO 这里可以处理释放背景恢复的效果 + }) + */ + } + + hide() { + nvMask.hide() + nvImageMenu.hide() + this.isShow = false + } +} + +export default NvImageMenu diff --git a/uni_modules/uni-share/js_sdk/uni-share.js b/uni_modules/uni-share/js_sdk/uni-share.js new file mode 100644 index 0000000..8af8631 --- /dev/null +++ b/uni_modules/uni-share/js_sdk/uni-share.js @@ -0,0 +1,98 @@ +import UniImageMenu from './uni-image-menu.js'; +class UniShare extends UniImageMenu{ + constructor(arg) { + super() + this.isShow = super.isShow + } + async show(param, callback){ + var menus = [] + plus.share.getServices(services => { //只显示有服务的项目 + services = services.filter(item => item.nativeClient) + let servicesList = services.map(e => e.id) + param.menus.forEach(item => { + if (servicesList.includes(item.share.provider) || typeof(item.share) == 'string') { + menus.push(item) + } + }) + super.show({ + list: menus, + cancelText: param.cancelText + }, e => { + callback(e) + if(e.event == 'clickMenu'){ + if (typeof(menus[e.index]['share']) == 'string') { + this[menus[e.index]['share']](param) + } else { + uni.share({ + ...param.content, + ...menus[e.index].share, + success: res=> { + console.log("success:" + JSON.stringify(res)); + super.hide() + }, + fail: function(err) { + console.log("fail:" + JSON.stringify(err)); + uni.showModal({ + content: JSON.stringify(err), + showCancel: false, + confirmText: "知道了" + }); + } + }) + } + } + }) + }, err => { + uni.showModal({ + title: '获取服务供应商失败:' + JSON.stringify(err), + showCancel: false, + confirmText: '知道了' + }); + console.error('获取服务供应商失败:' + JSON.stringify(err)); + }) + } + hide(){ + super.hide() + } + copyurl(param) { + console.log('copyurl',param); + uni.setClipboardData({ + data: param.content.href, + success: ()=>{ + console.log('success'); + uni.hideToast() //关闭自带的toast + uni.showToast({ + title: '复制成功', + icon: 'none' + }); + super.hide(); + }, + fail: (err) => { + uni.showModal({ + content: JSON.stringify(err), + showCancel: false + }); + } + }); + } + // 使用系统分享发送分享消息 + shareSystem(param) { + console.log('shareSystem',param); + plus.share.sendWithSystem({ + type: 'text', + content: param.content.title + param.content.summary || '', + href: param.content.href, + }, (e)=> { + console.log('分享成功'); + super.hide() + }, (err)=> { + console.log('分享失败:' + JSON.stringify(err)); + uni.showModal({ + title: '获取服务供应商失败:' + JSON.stringify(err), + showCancel: false, + confirmText: '知道了' + }); + }); + } +} +export default UniShare \ No newline at end of file diff --git a/uni_modules/uni-share/package.json b/uni_modules/uni-share/package.json new file mode 100644 index 0000000..4a2a3e1 --- /dev/null +++ b/uni_modules/uni-share/package.json @@ -0,0 +1,80 @@ +{ + "id": "uni-share", + "displayName": "uni-share", + "version": "2.0.0", + "description": "底部弹出宫格图标式的分享菜单,可覆盖原生组件。", + "keywords": [ + "分享菜单" +], + "repository": "", + "engines": { + "HBuilderX": "^3.1.0" + }, + "dcloudext": { + "category": [ + "JS SDK", + "通用 SDK" + ], + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "y" + }, + "H5-mobile": { + "Safari": "n", + "Android Browser": "n", + "微信浏览器(Android)": "n", + "QQ浏览器(Android)": "n" + }, + "H5-pc": { + "Chrome": "n", + "IE": "n", + "Edge": "n", + "Firefox": "n", + "Safari": "n" + }, + "小程序": { + "微信": "n", + "阿里": "n", + "百度": "n", + "字节跳动": "n", + "QQ": "n" + }, + "快应用": { + "华为": "n", + "联盟": "n" + }, + "Vue": { + "vue2": "y", + "vue3": "y" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-share/readme.md b/uni_modules/uni-share/readme.md new file mode 100644 index 0000000..de723a3 --- /dev/null +++ b/uni_modules/uni-share/readme.md @@ -0,0 +1,85 @@ +#### 本功能基于[底部图标菜单](https://ext.dcloud.net.cn/plugin?id=4858)封装而成。 +### 示例代码 +``` + + + +``` \ No newline at end of file diff --git a/unpackage/dist/dev/app-plus/app-service.js b/unpackage/dist/dev/app-plus/app-service.js index 4b3250a..79c226b 100644 --- a/unpackage/dist/dev/app-plus/app-service.js +++ b/unpackage/dist/dev/app-plus/app-service.js @@ -42133,7 +42133,7 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports, __webpack_require__) { "use strict"; -Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0; +/* WEBPACK VAR INJECTION */(function(__f__) {Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0; @@ -42323,7 +42323,10 @@ var _goods = __webpack_require__(/*! @/apis/interfaces/goods */ 103); -var _userAuth = _interopRequireDefault(__webpack_require__(/*! @/public/userAuth */ 104));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _createForOfIteratorHelper(o, allowArrayLike) {var it;if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {if (it) o = it;var i = 0;var F = function F() {};return { s: F, n: function n() {if (i >= o.length) return { done: true };return { done: false, value: o[i++] };}, e: function e(_e) {throw _e;}, f: F };}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion = true,didErr = false,err;return { s: function s() {it = o[Symbol.iterator]();}, n: function n() {var step = it.next();normalCompletion = step.done;return step;}, e: function e(_e2) {didErr = true;err = _e2;}, f: function f() {try {if (!normalCompletion && it.return != null) it.return();} finally {if (didErr) throw err;}} };}function _unsupportedIterableToArray(o, minLen) {if (!o) return;if (typeof o === "string") return _arrayLikeToArray(o, minLen);var n = Object.prototype.toString.call(o).slice(8, -1);if (n === "Object" && o.constructor) n = o.constructor.name;if (n === "Map" || n === "Set") return Array.from(o);if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);}function _arrayLikeToArray(arr, len) {if (len == null || len > arr.length) len = arr.length;for (var i = 0, arr2 = new Array(len); i < len; i++) {arr2[i] = arr[i];}return arr2;}var _default = +var _userAuth = _interopRequireDefault(__webpack_require__(/*! @/public/userAuth */ 104)); +var _uniShare = _interopRequireDefault(__webpack_require__(/*! uni_modules/uni-share/js_sdk/uni-share.js */ 646)); + +var _index = __webpack_require__(/*! @/apis/index.js */ 25);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _createForOfIteratorHelper(o, allowArrayLike) {var it;if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {if (it) o = it;var i = 0;var F = function F() {};return { s: F, n: function n() {if (i >= o.length) return { done: true };return { done: false, value: o[i++] };}, e: function e(_e) {throw _e;}, f: F };}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion = true,didErr = false,err;return { s: function s() {it = o[Symbol.iterator]();}, n: function n() {var step = it.next();normalCompletion = step.done;return step;}, e: function e(_e2) {didErr = true;err = _e2;}, f: function f() {try {if (!normalCompletion && it.return != null) it.return();} finally {if (didErr) throw err;}} };}function _unsupportedIterableToArray(o, minLen) {if (!o) return;if (typeof o === "string") return _arrayLikeToArray(o, minLen);var n = Object.prototype.toString.call(o).slice(8, -1);if (n === "Object" && o.constructor) n = o.constructor.name;if (n === "Map" || n === "Set") return Array.from(o);if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);}function _arrayLikeToArray(arr, len) {if (len == null || len > arr.length) len = arr.length;for (var i = 0, arr2 = new Array(len); i < len; i++) {arr2[i] = arr[i];}return arr2;}var uniShare = new _uniShare.default();var _default = { data: function data() { return { @@ -42345,6 +42348,17 @@ var _userAuth = _interopRequireDefault(__webpack_require__(/*! @/public/userAuth _this.coupons = res.coupons; }); }, + onBackPress: function onBackPress(_ref) + + {var from = _ref.from; + __f__("log", from, " at pages/goods/details.vue:219"); + if (from == 'backbutton') { + this.$nextTick(function () { + uniShare.hide(); + }); + return uniShare.isShow; + } + }, methods: { // 提交购买单 buyGoods: function buyGoods() { @@ -42433,7 +42447,42 @@ var _userAuth = _interopRequireDefault(__webpack_require__(/*! @/public/userAuth // 查看保障服务-隐藏 serveClose: function serveClose() { this.$refs.servePopup.close(); + }, + // 顶部菜单点击了分享功能 + onNavigationBarButtonTap: function onNavigationBarButtonTap() { + __f__("log", '点击了分享功能。。。', " at pages/goods/details.vue:318"); + uniShare.show({ + content: { //公共的分享参数配置 类型(type)、链接(herf)、标题(title)、summary(描述)、imageUrl(缩略图) + type: 0, + href: 'https://www.lianshang.vip/app?', + title: '链商星球,共创未来,一起搭建链商经济的世界~', + summary: '链商星球app你值得拥有~天天签到领福利~', + imageUrl: _index.config.apiUrls + 'images/top_logo.png' }, + + menus: [{ + "img": "/static/icons/payWay_icon_00.png", + "text": "微信好友", + "share": { //当前项的分享参数配置。可覆盖公共的配置如下:分享到微信小程序,配置了type=5 + "provider": "weixin", + "scene": "WXSceneSession" } }, + + + { + "img": "/static/icons/share-pyq.png", + "text": "微信朋友圈", + "share": { + "provider": "weixin", + "scene": "WXSenceTimeline" } }], + + + + cancelText: "取消分享" }, + function (e) {//callback + __f__("log", uniShare.isShow, " at pages/goods/details.vue:346"); + __f__("log", e, " at pages/goods/details.vue:347"); + }); } } };exports.default = _default; +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/vue-cli-plugin-uni/lib/format-log.js */ 39)["default"])) /***/ }), /* 362 */ @@ -72260,5 +72309,327 @@ var _default = { name: "NOList", /** } };exports.default = _default; +/***/ }), +/* 646 */ +/*!***********************************************************************************!*\ + !*** D:/链商星球电商/BlockChainH5(链商星球App最新)/uni_modules/uni-share/js_sdk/uni-share.js ***! + \***********************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(__f__) {Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;var _regenerator = _interopRequireDefault(__webpack_require__(/*! ./node_modules/@babel/runtime/regenerator */ 45));var _uniImageMenu = _interopRequireDefault(__webpack_require__(/*! ./uni-image-menu.js */ 647));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function ownKeys(object, enumerableOnly) {var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {var symbols = Object.getOwnPropertySymbols(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return Object.getOwnPropertyDescriptor(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function _objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {ownKeys(Object(source), true).forEach(function (key) {_defineProperty(target, key, source[key]);});} else if (Object.getOwnPropertyDescriptors) {Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));} else {ownKeys(Object(source)).forEach(function (key) {Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));});}}return target;}function _defineProperty(obj, key, value) {if (key in obj) {Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });} else {obj[key] = value;}return obj;}function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {Promise.resolve(value).then(_next, _throw);}}function _asyncToGenerator(fn) {return function () {var self = this,args = arguments;return new Promise(function (resolve, reject) {var gen = fn.apply(self, args);function _next(value) {asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);}function _throw(err) {asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);}_next(undefined);});};}function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}function _createClass(Constructor, protoProps, staticProps) {if (protoProps) _defineProperties(Constructor.prototype, protoProps);if (staticProps) _defineProperties(Constructor, staticProps);return Constructor;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function");}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });if (superClass) _setPrototypeOf(subClass, superClass);}function _setPrototypeOf(o, p) {_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {o.__proto__ = p;return o;};return _setPrototypeOf(o, p);}function _createSuper(Derived) {var hasNativeReflectConstruct = _isNativeReflectConstruct();return function _createSuperInternal() {var Super = _getPrototypeOf(Derived),result;if (hasNativeReflectConstruct) {var NewTarget = _getPrototypeOf(this).constructor;result = Reflect.construct(Super, arguments, NewTarget);} else {result = Super.apply(this, arguments);}return _possibleConstructorReturn(this, result);};}function _possibleConstructorReturn(self, call) {if (call && (typeof call === "object" || typeof call === "function")) {return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self) {if (self === void 0) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _isNativeReflectConstruct() {if (typeof Reflect === "undefined" || !Reflect.construct) return false;if (Reflect.construct.sham) return false;if (typeof Proxy === "function") return true;try {Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));return true;} catch (e) {return false;}}function _get(target, property, receiver) {if (typeof Reflect !== "undefined" && Reflect.get) {_get = Reflect.get;} else {_get = function _get(target, property, receiver) {var base = _superPropBase(target, property);if (!base) return;var desc = Object.getOwnPropertyDescriptor(base, property);if (desc.get) {return desc.get.call(receiver);}return desc.value;};}return _get(target, property, receiver || target);}function _superPropBase(object, property) {while (!Object.prototype.hasOwnProperty.call(object, property)) {object = _getPrototypeOf(object);if (object === null) break;}return object;}function _getPrototypeOf(o) {_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {return o.__proto__ || Object.getPrototypeOf(o);};return _getPrototypeOf(o);}var +UniShare = /*#__PURE__*/function (_UniImageMenu) {_inherits(UniShare, _UniImageMenu);var _super = _createSuper(UniShare); + function UniShare(arg) {var _thisSuper, _this;_classCallCheck(this, UniShare); + _this = _super.call(this); + _this.isShow = _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(UniShare.prototype)), "isShow", _thisSuper);return _this; + }_createClass(UniShare, [{ key: "show", value: function () {var _show = _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee( + param, callback) {var _this2 = this;var menus;return _regenerator.default.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0: + menus = []; + plus.share.getServices(function (services) {//只显示有服务的项目 + services = services.filter(function (item) {return item.nativeClient;}); + var servicesList = services.map(function (e) {return e.id;}); + param.menus.forEach(function (item) { + if (servicesList.includes(item.share.provider) || typeof item.share == 'string') { + menus.push(item); + } + }); + _get(_getPrototypeOf(UniShare.prototype), "show", _this2).call(_this2, { + list: menus, + cancelText: param.cancelText }, + function (e) { + callback(e); + if (e.event == 'clickMenu') { + if (typeof menus[e.index]['share'] == 'string') { + _this2[menus[e.index]['share']](param); + } else { + uni.share(_objectSpread(_objectSpread(_objectSpread({}, + param.content), + menus[e.index].share), {}, { + success: function success(res) { + __f__("log", "success:" + JSON.stringify(res), " at uni_modules/uni-share/js_sdk/uni-share.js:30"); + _get(_getPrototypeOf(UniShare.prototype), "hide", _this2).call(_this2); + }, + fail: function fail(err) { + __f__("log", "fail:" + JSON.stringify(err), " at uni_modules/uni-share/js_sdk/uni-share.js:34"); + uni.showModal({ + content: JSON.stringify(err), + showCancel: false, + confirmText: "知道了" }); + + } })); + + } + } + }); + }, function (err) { + uni.showModal({ + title: '获取服务供应商失败:' + JSON.stringify(err), + showCancel: false, + confirmText: '知道了' }); + + __f__("error", '获取服务供应商失败:' + JSON.stringify(err), " at uni_modules/uni-share/js_sdk/uni-share.js:51"); + });case 2:case "end":return _context.stop();}}}, _callee);}));function show(_x, _x2) {return _show.apply(this, arguments);}return show;}() }, { key: "hide", value: function hide() + + { + _get(_getPrototypeOf(UniShare.prototype), "hide", this).call(this); + } }, { key: "copyurl", value: function copyurl( + param) {var _this3 = this; + __f__("log", 'copyurl', param, " at uni_modules/uni-share/js_sdk/uni-share.js:58"); + uni.setClipboardData({ + data: param.content.href, + success: function success() { + __f__("log", 'success', " at uni_modules/uni-share/js_sdk/uni-share.js:62"); + uni.hideToast(); //关闭自带的toast + uni.showToast({ + title: '复制成功', + icon: 'none' }); + + _get(_getPrototypeOf(UniShare.prototype), "hide", _this3).call(_this3); + }, + fail: function fail(err) { + uni.showModal({ + content: JSON.stringify(err), + showCancel: false }); + + } }); + + } + // 使用系统分享发送分享消息 + }, { key: "shareSystem", value: function shareSystem(param) {var _this4 = this; + __f__("log", 'shareSystem', param, " at uni_modules/uni-share/js_sdk/uni-share.js:80"); + plus.share.sendWithSystem({ + type: 'text', + content: param.content.title + param.content.summary || '', + href: param.content.href }, + function (e) { + __f__("log", '分享成功', " at uni_modules/uni-share/js_sdk/uni-share.js:86"); + _get(_getPrototypeOf(UniShare.prototype), "hide", _this4).call(_this4); + }, function (err) { + __f__("log", '分享失败:' + JSON.stringify(err), " at uni_modules/uni-share/js_sdk/uni-share.js:89"); + uni.showModal({ + title: '获取服务供应商失败:' + JSON.stringify(err), + showCancel: false, + confirmText: '知道了' }); + + }); + } }]);return UniShare;}(_uniImageMenu.default);var _default = + +UniShare;exports.default = _default; +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/vue-cli-plugin-uni/lib/format-log.js */ 39)["default"])) + +/***/ }), +/* 647 */ +/*!****************************************************************************************!*\ + !*** D:/链商星球电商/BlockChainH5(链商星球App最新)/uni_modules/uni-share/js_sdk/uni-image-menu.js ***! + \****************************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}function _createClass(Constructor, protoProps, staticProps) {if (protoProps) _defineProperties(Constructor.prototype, protoProps);if (staticProps) _defineProperties(Constructor, staticProps);return Constructor;}var nvMask, nvImageMenu;var +NvImageMenu = /*#__PURE__*/function () { + function NvImageMenu(arg) {_classCallCheck(this, NvImageMenu); + this.isShow = false; + }_createClass(NvImageMenu, [{ key: "show", value: function show(_ref, + + + + callback) {var _this = this;var list = _ref.list,cancelText = _ref.cancelText; + if (!list) { + list = [{ + "img": "/static/sharemenu/wechatfriend.png", + "text": "图标文字" }]; + + } + //以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心 + var screenWidth = plus.screen.resolutionWidth; + //以360px宽度屏幕为例,上下左右边距及2排按钮边距留25像素,图标宽度55像素,同行图标间的间距在360宽的屏幕是30px,但需要动态计算,以此原则计算4列图标分别的left位置 + //图标下的按钮文字距离图标5像素,文字大小12像素 + //底部取消按钮高度固定为44px + //TODO 未处理横屏和pad,这些情况6个图标应该一排即可 + var margin = 20, + iconWidth = 60, + icontextSpace = 5, + textHeight = 12; + var left1 = margin / 360 * screenWidth; + var iconSpace = (screenWidth - left1 * 2 - iconWidth * 4) / 3; //屏幕宽度减去左右留白间距,再减去4个图标的宽度,就是3个同行图标的间距 + if (iconSpace <= 5) {//屏幕过窄时,缩小边距和图标大小,再算一次 + margin = 15; + iconWidth = 40; + left1 = margin / 360 * screenWidth; + iconSpace = (screenWidth - left1 * 2 - iconWidth * 4) / 3; //屏幕宽度减去左右留白间距,再减去4个图标的宽度,就是3个同行图标的间距 + } + var left2 = left1 + iconWidth + iconSpace; + var left3 = left1 + (iconWidth + iconSpace) * 2; + var left4 = left1 + (iconWidth + iconSpace) * 3; + var top1 = left1; + var top2 = top1 + iconWidth + icontextSpace + textHeight + left1; + + var TOP = { + top1: top1, + top2: top2 }, + + LEFT = { + left1: left1, + left2: left2, + left3: left3, + left4: left4 }; + + + nvMask = new plus.nativeObj.View("nvMask", { //先创建遮罩层 + top: '0px', + left: '0px', + height: '100%', + width: '100%', + backgroundColor: 'rgba(0,0,0,0.2)' }); + + nvImageMenu = new plus.nativeObj.View("nvImageMenu", { //创建底部图标菜单 + bottom: '0px', + left: '0px', + height: (iconWidth + textHeight + 2 * margin) * Math.ceil(list.length / 4) + 44 + + 'px', //'264px', + width: '100%', + backgroundColor: 'rgb(255,255,255)' }); + + nvMask.addEventListener("click", function () {//处理遮罩层点击 + // console.log('处理遮罩层点击'); + _this.hide(); + callback({ + event: "clickMask" }); + + }); + var myList = []; + list.forEach(function (item, i) { + myList.push({ + tag: 'img', + src: item.img, + position: { + top: TOP['top' + (parseInt(i / 4) + 1)], + left: LEFT['left' + (1 + i % 4)], + width: iconWidth, + height: iconWidth } }); + + + myList.push({ + tag: 'font', + text: item.text, + textStyles: { + size: textHeight }, + + position: { + top: TOP['top' + (parseInt(i / 4) + 1)] + iconWidth + icontextSpace, + left: LEFT['left' + (1 + i % 4)], + width: iconWidth, + height: textHeight } }); + + + }); + + //绘制底部图标菜单的内容 + nvImageMenu.draw([{ + tag: 'rect', //菜单顶部的分割灰线 + color: '#e7e7e7', + position: { + top: '0px', + height: '1px' } }, + + + { + tag: 'font', + text: cancelText, //底部取消按钮的文字 + textStyles: { + size: '14px' }, + + position: { + bottom: '0px', + height: '44px' } }, + + + { + tag: 'rect', //底部取消按钮的顶部边线 + color: '#e7e7e7', + position: { + bottom: '45px', + height: '1px' } }].concat( + + + myList)); + + nvMask.show(); + nvImageMenu.show(); + // 开始动画 + /* + plus.nativeObj.View.startAnimation({ + type: 'slide-in-bottom', + duration: 300 + }, nvImageMenu, {}, function() { + console.log('plus.nativeObj.View.startAnimation动画结束'); + // 关闭原生动画 + plus.nativeObj.View.clearAnimation(); + nvImageMenu.show() + }); + */ + + + this.isShow = true; + nvImageMenu.addEventListener("click", function (e) {//处理底部图标菜单的点击事件,根据点击位置触发不同的逻辑 + // console.log("click menu"+JSON.stringify(e)); + if (e.screenY > plus.screen.resolutionHeight - 44) {//点击了底部取消按钮 + // callback({event:"clickCancelButton"}) + _this.hide(); + } else if (e.clientX < 5 || e.clientX > screenWidth - 5 || e.clientY < 5) { + //屏幕左右边缘5像素及菜单顶部5像素不处理点击 + } else {//点击了图标按钮 + var iClickIndex = -1; //点击的图标按钮序号,第一个图标按钮的index为0 + var iRow = e.clientY < top2 - left1 / 2 ? 0 : 1; + var iCol = -1; + if (e.clientX < left2 - iconSpace / 2) { + iCol = 0; + } else if (e.clientX < left3 - iconSpace / 2) { + iCol = 1; + } else if (e.clientX < left4 - iconSpace / 2) { + iCol = 2; + } else { + iCol = 3; + } + if (iRow == 0) { + iClickIndex = iCol; + } else { + iClickIndex = iCol + 4; + } + // console.log("点击按钮的序号: " + iClickIndex); + // if (iClickIndex >= 0 && iClickIndex <= 5) { //处理具体的点击逻辑,此处也可以自行定义逻辑。如果增减了按钮,此处也需要跟着修改 + // } + callback({ + event: "clickMenu", + index: iClickIndex }); + + } + }); + /* nvImageMenu.addEventListener("touchstart", function(e) { + if (e.screenY > (plus.screen.resolutionHeight - 44)) { + //TODO 这里可以处理按下背景变灰的效果 + } + }) + nvImageMenu.addEventListener("touchmove", function(e) { + //TODO 这里可以处理按下背景变灰的效果 + if (e.screenY > plus.screen.resolutionHeight - 44) {} + }) + nvImageMenu.addEventListener("touchend", function(e) { + //TODO 这里可以处理释放背景恢复的效果 + }) + */ + } }, { key: "hide", value: function hide() + + { + nvMask.hide(); + nvImageMenu.hide(); + this.isShow = false; + } }]);return NvImageMenu;}();var _default = + + +NvImageMenu;exports.default = _default; + /***/ }) ],[[0,"app-config"]]]); \ No newline at end of file